Prompt
stringlengths
14
160
Instruction
stringlengths
18
2k
Response
stringlengths
8
2k
Gunicorn and Django with Upstart and Nginx
First of all I have many Django instances setup and running like this.In each project I have a script.sh shell script that starts gunicorn etc.:#!/bin/bash set -e LOGFILE=/var/log/gunicorn/app_name.log LOGDIR=$(dirname $LOGFILE) NUM_WORKERS=3 # user/group to run as USER=root GROUP=root PORT=8060 IP=12...
Well, I figured it out. If any one ever run into something like this...Its basically a lack of knowledge about shell scripts that was holding me back.After commenting out each line o the script file i found the problem with the line :source ../bin/activateand all after that.The problem was that it had 2 spaces on front...
What's the purpose of setting "X-Forwarded-For" header in nginx
I have the following Nginx configuration for my Django application:upstream api { server localhost:8000; } server { listen 80; location / { proxy_pass http://api; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; ...
From theMozilla docsTheX-Forwarded-For(XFF) header is a de-facto standard header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or a load balancer. When traffic is intercepted between clients and servers, server access logs contain the IP address of the proxy or ...
How do I add the x-forwarded-for field to my access logs for the nginx ingress controller?
I'm using the nginx ingress controller on gke, by default these are what my access logs look like:"10.123.0.20 - [10.123.0.20] - - [22/Apr/2019:18:47:59 +0000] "GET /sdflksdf/sdfsdf HTTP/2.0" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/538.12 (KHTML, like Gecko) Chrome/73.0.3683.100 Safari/53...
You should use a ConfigMap tocustomize the NGINX configuration:ConfigMapsallow you to decouple configuration artifacts from image content to keep containerized applications portable.The ConfigMap API resource stores configuration data as key-value pairs. The data provides the configurations for system components fo...
How to match all locations in nginx, for auth?
I need an expression to match all requests, no matter what.Is this good enough?location ~ ^/I'm worried about other locations taking precedence, bypassing my auth.
You can putngx_http_auth_basic_modulesettings into any of the following contexts:http, server, location, limit_exceptYour versionlocation ~ ^/Would work only if you don't have another declared locations in yourserversectionexample:server { ... #some server settings location / { # full equivalent for "~ ^/" ...
custom HTTP headers for static files with Django
I'm writing an image bank with Django, and I want to add a button to get a hi-res version of an image (the low-res is shown in the details page). If I put just anlink, the browser will open the image instead of downloading it. Adding an HTTP header like:Content-Disposition: attachment; filename="beach008.jpg"works, ...
If your django app is proxied by nginx you can usex-accell-redirect. You need to pass a special header in your response, nginx will intercepet this and start serving the file, you can also pass Content-Disposition in the same response to force a download.That solution is good if you want to control which users acess th...
Next.js App reloads frequently in production
I've just deployed my first Next.js app in production through Nginx and pm2. Everything seems okay but the app frequently reloads after some interval on browser. I'm seeing thewebpack-hmris also running in myproductionserver. (Which I think isn't necessary in production)I am using a customserver.jsand I run my app on p...
Finally found a solution. I had to tell my env mode when starting pm2 aspm2 start server --env production. And it works perfectly on my browser.
VueJS Router History Mode behind Nginx
My IssueI've read through theofficial documentationfor putting VueJS router in history mode behind Nginx as well as the following:Stackoverflow - vue-router, nginx and direct linkStackoverflow - How to config nginx for Vue-router on DockerAfter reviewing all these and making the changes multiple times, I'm still unable...
So, I reached out to another developer at work and when they were reviewing the setup and pointed out that I had/have a typo in my Dockerfile:COPY prod_nginx.conf /etc/nginx/nginx.confgNeeds to be:COPY prod_nginx.conf /etc/nginx/nginx.confSilly little typos! Once I had this fixed, Nginx and Router worked!
Nginx conf how to remove leading slash from $uri
My Nginx conf file :location / { try_files $uri $uri/ /index.php?url=$uri; } ## PHP conf in case it's relevant location ~ \.php$ { fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include /etc/nginx/fastcgi.conf; fastcgi_param SCRIPT_FILENAME $document_ro...
Use a named location and an internal rewrite. For example:location / { try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/(.*)$ /index.php?url=$1 last; }Seethis documentfor more.
Nginx - Wordpress blog on Rails loads styles and scripts with mime type text/html
I just installed a Wordpress blog under a /blog directory within a Rails app, running on Unicorn and Nginx, and my stylesheets and scripts aren't being loaded properly in the browser when I go to my domain.com/blog pages. Chrome console's giving me the following error:Resource interpreted as Stylesheet but transferred ...
After a ton of searching around, I finally foundthis solution.Seems like the issue was that I needed to add a root to the app within "location /blog" and nest the "location ~ .php$" within /blog. Here's my Nginx config that's working now for a Wordpress blog in a Rails app using Unicorn, in case anyone else needs it:up...
MySql server PID not found
I have CentOS 6.4 with NGINX.When I try tostart/stop/restartmysql server(/etc/init.d/mysqld restart)I get this error:MySQL server PID file could not be found! [FAILED] Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/mysqld.pid).What can I do to solve this problem?Thanks!
I got the same error on a CentOS 6.3 where I upgraded MySQL to 5.6.14 but I kept the old my.cnf file. After upgrade, MySQL did not start anymore, giving me the same error as you described.The problem was that I had this setting in my.cnf:table_cache=2048According to this linktable_cache renamed table_open_cache.."Seem ...
Nginx cache inactive vs proxy_cache_valid
Nginx cache config:proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off; server { # ... location / { proxy_cache my_cache; proxy_cache_valid 5m; proxy_pass http://my_upstream; } }inactiveinactive specifies ho...
Fromthisblog two quotes:Turns out proxy_cache_valid instructs Nginx that the resource could be cached for 1y IF the resource doesn’t become inactive first. When you request a resource that has longer expiration but has become inactive due lack of requests, it causes a cache miss.Conclusion proxy_cache_path should have ...
Is it possible to pass request to php-fpm without nginx having volume mounted
I'm trying to migrate my legacy monolith to k8s, now I have nginx and php-fpm (with code) images and I want nginx to just serve http traffic and pass it to fpm, but nginx insist on having files, I don't havetry_filesdirective, but it tries to find root and index files anyways.So is it at all possible to not mount sourc...
The problem is that theindexdirective needs the fileindex.phpto exist, in order to internally redirect the URI/to/index.php.You can avoid theindexdirective by adding alocation /to internally redirect everything to/index.php.For example:location / { rewrite ^ /index.php last; } location ~* \.php$ { root /var/www...
DOCKERFILE: Running multiple CMD. (Starting NGINX and PHP) [duplicate]
This question already has answers here:Why can't I use Docker CMD multiple times to run multiple services?(5 answers)Closed5 years ago.I have a dockerfile that sets up NGINX, PHP, adds a Wordpress Repository. I want at boot time, to start PHP and NGINX. However, I am failing to do so. I tried adding the two commands in...
start.sh#!/bin/bash /usr/sbin/service php7.0-fpm start /usr/sbin/service nginx start tail -f /dev/nullDockerfileCOPY ["start.sh", "/root/start.sh"] WORKDIR /root CMD ["./start.sh"]With this, you can put more complex logic instart.sh.
keycloak Invalid parameter: redirect_uri behind a reverse proxy
How do you correctly configure NGINX as a proxy in front of Keycloak?Asking & answering this as doc because I've had to do it repeatedly now and forget the details after a while.This is specifically dealing with the case where Keycloak is behind a reverse proxy e.g. nginx and NGINX is terminating SSL and pushing to Key...
The key to this is in the docs athttps://www.keycloak.org/docs/latest/server_installation/index.html#identifying-client-ip-addressesTheproxy-address-forwardingmust be set as well as the variousX-...headers.If you're using the Docker image fromhttps://hub.docker.com/r/jboss/keycloak/then set the env. arg-e PROXY_ADDRESS...
How to configure NGINX SSL (SNI)
I have this NGINX configuration as follows:# jelastic is a wildcard certificate for *.shared-hosting.xyz server { listen 443; server_name _; ssl on; ssl_certificate /var/lib/jelastic/SSL/jelastic.chain; ssl_certificate_key /var/lib/jelastic/SSL/jelastic.key; } # fullchain2 is a...
Theserver_name _;is irrelevant (and is not required in modern versions ofnginx). If aserverwith a matchinglistenandserver_namecannot be found,nginxwill use thedefault server.In the absence of adefault_serversuffix to thelistendirective,nginxwill use the firstserverblock with a matchinglisten.If your configurations are ...
Unicorn vs Passenger Standalone behind nginx [closed]
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened,visit the help ...
If you already have nginx set up, use Unicorn. If not, use Passenger Standalone, which comes with its own builtin nginx. Perhaps this also shapes your approach to the docs. There's not much point to separately documenting what is essentially two very well documented products, bundled together.You'll hear good things ab...
Heroku Nginx HTTP 413 entity too large
I'm gettingerror 413when uploading a 4MB file. I have already created a.user.inifile on thepublic/folder. to allow up to 10 MB filesSo I usedclient_max_body_sizelike this on mynginx.conf,but I still get 413.location / { index index.php; try_files $uri $uri/ /index.php?$query_string; client_max_body_size 10M...
Perhaps a bit late, but in order to fix this, move yourclient_max_body_size 10M;outside of the location section. Like this:client_max_body_size 10M; location / { index index.php; try_files $uri $uri/ /index.php?$query_string; }Seehttps://github.com/heroku/heroku-buildpack-php/blob/beta/conf/nginx/heroku.conf.p...
How to set location with extension in NGINX server
I'm new with NGINX server and I was wondering how to set something like this.location phpmyadmin \.(gif|jpg|png)$ { root /usr/share/phpmyadmin; }example above fails at server restart.Thanks for all answers.UPDATE:location ~* .(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|html|htm|wml)$ { roo...
If you want to use regex, use~(for case-sensitive matching) or~*(for case-insensitive matching). Your location block should look like this:location ~ "phpmyadmin \.(gif|jpg|png)$" { root /usr/share/phpmyadmin; }You can read more here:http://nginx.org/en/docs/http/ngx_http_core_module.html#location
How to dump Symfony2 routes to nginx?
I have read that I should dump symfony2 routes into my web server to bypass the symfony2 router, for performance. I found an example forapache.How would you go about doing this for nginx?
Currently, because of the way nginx is built, this is not possible.https://github.com/symfony/symfony/issues/2432
Rails - Nginx needs to be restarted after deploying with Capistrano?
I am using Capistrano to deploy my Rails application. whenever I deploy, changes would not be reflected on the browser, and I still need to restart nginx to update the site (running sudo /etc/init.d/nginx restart). I'm not really sure why but isn't it supposed to be updated after restarting application? (using touch /a...
I realized that the deployment setup matcheshttp://coding.smashingmagazine.com/2011/06/28/setup-a-ubuntu-vps-for-hosting-ruby-on-rails-applications-2/When I followed this tutorial(about a year ago), I installed slightly newer versions of nginx and passenger. From what I remember, I think these newer versions prompted m...
Overwrite Cache-Control: Private in Nginx
Just wonder if there is any way to overwrite / drop the response back Cache-Control: private from a proxied remote server. The setup architecture looks like this (yes, it's a reverse-proxy set up):[my server] --> [remote server]The setting for my server site-available/default:server { listen 80; ## listen fo...
You wantproxy_hide_headerinstead of proxy_ignore_headers
gzip - questions about performance
Firstly, I'm using Django. Django provides gzip middleware which works just fine. Nginx also provides a gzip module. Would it make more sense to just use Nginx's gzip module because it is implemented purely in C, or are there other performance considerations I'm missing.Secondly, Django doesn't gzip anything under 200 ...
1) I imagine that one gzip compression is enough and nginx is faster, although I haven't benchmarked it yet.GzipMiddlewareutilizes a few built-ins, which might be well optimized, too.# From http://www.xhaus.com/alan/python/httpcomp.html#gzip # Used with permission. def compress_string(s): import cStringIO, gzip ...
Nginx: preserve port during redirect
I have an Nginx server listening on80ran inside a Docker container.Inside the Nginx config I need to perform a redirect to a static page in specific situations.rewrite ^ /foobar.html redirect;The user can run the container specifying any port using the docker command line (for reference, she can expose the container on...
So, I found a solution, I can specify the redirect as follows:rewrite ^ $scheme://$http_host/foobar.html redirect;This will preserve the port.
nginx/apache redirection for output port on docker container on vps
I'm a linux noob in admin of docker container using apache or nginx on VPS.I use an OVH classic Vps (4go ram, 25Go SSD) with already installed image of ubuntu 15.04 + docker.Install of docker container is really easy, and in my case i install without problem the imagesharelatex.docker run -d \ -v ~/sharelatex_data:/v...
Previous answers probably covers most of the issues, especially if there were redirection problems of your domain name.In order to be fully portable and use all the possibilities of docker, my recommendation would be to used the Nginx official docker image and make it the only one accessible from the outside (with the ...
How to decode "Content-Encoding: gzip, gzip" using curl?
I am trying to decode the webpage www.dealstan.com using CURL by using the below code:$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // Define target site curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return page in string curl_setopt($cr, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US...
You can decode it by trimming off the headers and using gzinflate.$url = "http://www.dealstan.com" $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // Define target site curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return page in string curl_setopt($cr, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows...
Best practices for linux user permissions to run web application as?
I see a lot of different advice online as to where to serve your web application from, what user to run it as, etc.For instance, I've seen it served from: /var/www/site, /srv/www/site, /home/$USER/site.I've seen the user be www-data, $USER (i.e. my user account), or a custom user specifically created for that purpose (...
For location, choose what seems best to you. Here are some considerations to help out:Locations under/varare for files whichchange in size, or generally are "variable."/srvgenerally indicates files related to some service running on the machine./homeshould usually be reserved for interactive users. You can set a system...
Tomcat occasionally returns a response without HTTP headers
I’m investigating a problem where Tomcat (7.0.907.0.92) returns a response with no HTTP headers very occasionally.According to the captured packets by Wireshark, after Tomcat receives a request it just returns only a response body. It returns neither a status line nor HTTP response headers.It makes a downstream Nginx i...
It turned out that the "sjsxp" library which JAX-WS RI v2.1.3 uses makes Tomcat behave this way. I tried a different version of JAX-WS RI (v2.1.7) which doesn't use the "sjsxp" library anymore and it solved the issue.A very similar issue posted on Metro mailing list:http://metro.1045641.n5.nabble.com/JAX-WS-RI-2-1-5-re...
Can all Nginx vhosts share the same ssl_session_cache?
To me,the Nginx docs about howssl_session_cacheworks, is a bit unclear. I'm wondering if this:ssl_session_cache shared:SSL:10m;declared either in thehttpblock, or ineachserver(i.e. virtual host) block, results in 1) one single global cache namedSSL, 10 MB large. Or 2) in one 10 MB cache per server, with combined size o...
Looking at the implementation ofssl_session_cachebyngx_http_ssl_session_cacheinnxg_http_ssl_module.c, it creates one shared memory zone named "SSL", i.e. one ssl session cache.Any subsequent call tossl_session_cacheretrieves the previously configured shared memory zone named "SSL", instead of creating a new one (cmp.ng...
ASP.NET 5 behind nginx
I have a ASP.NET 5 MVC6 application behind a Nginx server that acts as a reverse proxy. Its configuration is :server { listen 80; server_name example.com; location / { proxy_pass http://localhost:5000; client_max_body_size 50M; proxy_set_header Host $host; }...
This is aknown issuein rc1. The current work around is to add the following to your nginx configuration;proxy_set_header Connection keep-alive;Fixis scheduled for rc2.
Clean /var/log/nginx logs file
I have over 10.0G logs under /var/log and /var/log/nginx. How can I safely clean it?7.8G /var/log/nginx/custom 2.0G /var/log/nginx 2.0G /var/log
To control application's lifecycle Unix provides a mechanism called Unix signals. USR1 is custom and usually handles the log rotation, other signal like HUP is standard and performs reload.http://nginx.org/en/docs/control.htmlTERM, INT fast shutdown QUIT graceful shutdown HUP changing configuration, keeping up wit...
Rails shows IP as 127.0.0.1 when accessed from private NIC, but Nginx shows the correct IP. Public IP gets forwarded fine
We are running a Rails application on Unicorn + Nginx. The server has two NICs that we use.eth0handles requests for the public internet, andeth2handles requests from our private network.When a request comes througheth0, the nginx logs show the public IP, and the Rails logs also show this IP. However, when a request com...
The issue was that Rails thinks any192.168.x.xaddress is a private address, so strips them from theX-Forwarded_Forheader.# IP addresses that are "trusted proxies" that can be stripped from # the comma-delimited list in the X-Forwarded-For header. See also: # http://en.wikipedia.org/wiki/Private_network#Private_IPv4_add...
Setting up Tornado with Nginx on Ubuntu 10.04 for production use
I understand that there's an nginx configuration file athttp://www.friendfeed.comBut i don't really know how to set up Tornada for production use on Ubuntu 10.04 with Nginx.Here's my situation and assumptions: 1) Assuming my Tornado project is set up as such:project/ src/ static/ templates/ ...
This could help a lot:https://github.com/chaselee/tornado-linodeCheck out the link in the Readme to see how to deploy in production on Ubuntu 10.04.Basically I keep the nginx conf in my repo, which gets pulled into the server, and the conf file is symlinked into the actual nginx directory where it needs to go.
NGINX and PHP-FPM is downloading index.php instead of processing it
I recently installed NGINX and PHP-FPM on a Centos6 server. I'm able to view other php pages on my site, but for some reason my index.php file gets downloaded rather than processed like a normal php page.Here is the nginx config:# The default server # server { listen 80 default_server; server_name example.com; ...
Try to remove this block:location = /index.php { root /var/www/html; }
PHP-FPM + Nginx on Kubernetes
We're hosting a lot of different applications on our Kubernetes cluster already - mostly Java based.For PHP-FPM + Nginx our approach is currently, that we're building a container, which includes PHP-FPM, Nginx and the PHP application source code. But this actually breaks with the one-process-per-container docker rule, ...
This is a good question because there is an important distinction that gets elided in most coverage of container architecture- that between multithreaded or event-driven service applications and multiprocess service applications.Multithreaded and event-driven service applications are able with a single process to handl...
Nginx to host app in different location [closed]
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, ...
After so many hours trying a lot of combinations, the way I got it working was:location ^~ /status { alias /mnt/data/site/www-cachet/public; try_files $uri $uri/ @status; location = /status/ { rewrite /status/$ /status/index.php; } location ~ ^/status/(.+\.php)$ { fastcgi_pass uni...
nginx 504 Gateway Time-out
I'm running a rails3.0.7 project with phusion-passenger on nginx. While I was doing a ajax which took about 15 mins to process. It jump up an error with firebug which said "504 Gateway Time-out" after 10 mins from calling the ajax.Could someon give me some idea of how I could find the problem.Thanks, benenvironmentOS: ...
That's an nginx timeout error. Look at the following article for some clues as to which parameter you need to adjust to avoid the timeout, if you really want to allow more than 10 minutes to complete the task.How do I prevent a gateway timeout with nginx
nginx and trailing slashes on $document_root?
I use the following configuration for nginx:http://gist.github.com/340956However, this configuration causes aNo input file specifiederror with PHP. The only way I have been able to solve it is by altering this line:fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;Note the "/" between$document_roota...
Just faced the same issue (in remi installation of nginx+php-fpm on a RHEL6 server), you can solve it by adding the following line in /etc/nginx/fastcgi_paramsfastcgi_param SCRIPT_FILENAME $request_filename;I found this line missing in RHEL, while present in a perfectly working Debian nginx.
Load balancer for Azure Service Fabric Cluster on-premises
As developers we wrote microservices on Azure Service Fabric and we can run them in Azure in some sort of PaaS concept for many customers. But some of our customers do not want to run in the cloud, as databases are on-premises and not going to be available from the outside, not even through a DMZ. It's ok, we promised ...
Very similar problem, we have a many services and Service Fabric Cluster that runs on-premises. When it's time to use the load balancer we install IIS on the same machine where Service Fabric cluster runs. As the IIS is a good load balancer we use IIS as a reverse proxy only for API Gateway. Kestrel hosting is using fo...
Expire assets cache in browsers when replacing fingerprinted files server via nginx
I'm serving a single page JavaScript application via nginx and when I deploy new version, I want to force browsers to invalidate their JS cache and request/use the newest version available.So for example when I replace a file on the server's folder, namedmy-app-8e8faf9.js, with a file namedmy-app-eaea342.js, I don't wa...
Invalidating cache by changing assets urls is a normal practice.But for that to work you need your html files not to be cached forever so that browser will have some info when these names change.So separate locations for html and assets. Matcher can be different, depending on how you store them, for example:location / ...
Compile assets automatically and serve them with nginx (development)
I'm working on a Rails app with a high number of assets, which sadly cannot be reduced. In production this is not a problem, but in development, ~20 asset requests per visited page cannot be quickly served by an application server (like webrick or Thin).So I started using nginx in development for serving anything inpub...
This setup worked for me:Include the nginx port inconfig.asset_hostconfig.assets.debug = falseconfig.assets.digest = trueconfig.assets.compile = truebefore starting the Rails server, runrm -rf public/assets; rake tmp:clear tmp:cache:clear assets:clean assets:precompilelaunch the Rails serverOn every asset change, runra...
How to remove certain cookies from nginx response [closed]
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, ...
Although you already mentioned that you switched to Varnish to accomplish what you asked for, the correct answer would have been to use theheaders-more-nginx-modulewhich basically allows you the same as the Varnish function does (and much more).
Try_files does not hit PHP ( NginX configuration)
Below is my nginx.conf.In case of non existing files/index.phpis served fine.But when my URL is/foo/bar => /foo/bar/index.phpis served as PHP source code via download.Any ideas?try_files $uri $uri/ $uri/index.php /index.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $docum...
Solution was to addindex index.phpindex index.php try_files $uri $uri/ $uri/index.php /index.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
Nginx proxy_pass redirect to URL from query string
I'm using Nginx and trying to redirect using proxy_pass to a URL that comes as a query string. I also want to avoid passing any other parameters to that URL.This is the url I'm sending to the proxy:http://10.10.10.10/proxydownload?url=http://www.test.com/d/guid/download&session=123This is what I have in the nginx.conf:...
This happens because when you hardcode the value passed tohttp://nginx.org/r/proxy_pass, without using any variables, then the default resolver, from/etc/resolv.conf, is used at the time that the configuration is parsed and loaded — any subsequent changes in the IP address won't be picked up.If, instead, you use variab...
Kubernetes Ingress controllers for wildcard url mapping
I need for each of my users to access a service at a custom url eg. abccompany.mycloudapp.com , each service being a kubernetes service I'm looking at ingress controllers but I need a way to use a wildcard host field and somehow read the value into the path: and service: fields ; here's a sample ingress controller of w...
If you use the stock controllers you will be able to switch on hostname and go to different backends services. It sounds like you don't want to enumerate all the subdomains -> service mappings, in which case you probably need to write your own controller that writes out an nginx config that uses $http_host in the appro...
Best way to send email when PHP process dies
I wrote a quick PHP page to handle 502 requests. Nginx will re-direct to this page when a 502 is encountered and an email is fired off.The problem is, most of the time that the 502 is encountered is because PHP has died, so writing to the DB and sending an email using PHP is no longer possible. Tweaks to PHP-FPM settin...
Here is what I've ended up doing. I've not rolled it out to our prod servers yet, but all testing thus far looks good.Nginx does not support CGI natively, so you need another means to do it.thttpdfit the bill nicely. There is a good write up the nginxwikishowing how to use it.I configured thttpd with the following:dir=...
NGINX download slow to start with send_file
I have a download link that goes to a method in a controller which uses send_file so that I may rename the file (it is an MP3 with a uuid as a filename). After clicking on the link I see the request in the NGINX logs and Rails logs, however it takes up to 90 seconds before the download beings. I have tried various sett...
After testing I found out it was turbolinks causing the issue. It was doing a XHR request in the background, downloading the file first then allowing the browser to actually download the file. After adding 'data-no-turbolink'='true' to my link, do files download instantly.
Nginx with phpmyadmin wrong redirect after login
I'm setting up phpMyAdmin with nginx. I can visit phpMyAdmin athttp://localhost/phpmyadmin. However, when I logged in, the URL is redirected tohttp://localhost/sql.phpinstead ofhttp://localhost/phpmyadmin/sql.php.I have phpMyAdmin symlinked in my /var/www/html/ folder.sudo ln -s /usr/share/phpmyadmin /var/www/html/phpm...
I have actually been through so many solutions on StackOverflow today and sadly none of which work and some even given some horrid recommendations. What's scary is how many I came across that were marked as answers.I just did a brand new Ubuntu 16.04 LEMP server, everything cleanly installed this morning Nginx, mySQL, ...
Compare nginx+Apache+mod_wsgi vs nginx+uWSGI?
What advantages and disadvantages using nginx+Apache+mod_wsgi vs nginx+uWSGI(vurtualenv) in productionAdvantages of first variant using i see in that mod_wsgi developing since 2007 and have more stable version and easy administratedAdvantages of second variant is more high perfomance (seeBenchmark of Python WSGI Server...
When you load your typical large Python web application on top of the most popular WSGI servers, the performance difference isn't actually that much and usually nothing to get excited about. Hello world benchmarks like the one you quote are very misleading as they test a very narrow use case and the configurations used...
Configure timezone in dockerized Nginx + PHP-FPM
I need to set the default timezone in a Dockerfile. I have two containers (nginx and php7-fpm).When I enter the PHP container's bash and runphp --info | grep timezoneI get:Default timezone => UTCdate.timezone => no value => no valueMy dockerfiles are the following:nginx/Dockerfile:FROM debian:jessie RUN apt-get update...
There are two type of Time zone settings. One is a system level. That you can set using/etc/localtimeSee the Dockerfile steps belowENV TZ=America/Los_Angeles RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezonePS: Taken fromhttps://serverfault.com/questions/683605/docker-container-time-timezon...
Simulate poor bandwidth in a testing environment (Mac OS X)?
We have a customized Flash/HTML5 video player we use for users on our site. I'm currently fleshing out the experience for users who have 'suboptimal' bandwidth--basically we'd like the client side code to be able to detect poor user experience due to excessive buffering. I would like to test this "poor bandwidth" handl...
Just use nginx's configuration.While OS X Lion's Network Link Conditioner works as expected it's stillannoyingto use when I'm really just trying to test a subset of a web app's behavior--i.e., the slow video buffering handling system.As such, I've found it much more convenient to set rate limiting in mynginx.conffile, ...
nginx: How to keep double slashes in urls
I have web service which takes several filter parameters, something like :http://mydomain.com/filter1/value1/filter2/value2/filter3/value3The tricky thing is sometimes some of the filter variables are absent, so urls as such could be passed to this service:http://mydomain.com/filter1//filter2//filter3/value3Now I need ...
syntax: merge_slashes [on|off] default: merge_slashes on context: http, serverYou must use:merge_slashes off;
NGINX server configuration for Codeigniter
/etc/nginx/conf.d/default.confserver{ listen 80; listen [::]:80; server_name 192.168.56.101 192.168.101.100 localhost; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { ...
I didn't want to change the current document root (/var/www/html) since my 'ci' folder is located at/var/www/html/ci.So instead, I created a new location block in/etc/nginx/conf.d/default.conf:server{ ... location /ci { try_files $uri $uri/ /ci/index.php?/$request_uri; } ... }Thanks toMert Öksüzfor sugg...
How to make nginx virtual directories accessible in php?
Let's say I have a web server (nginx)server.comwhere I have only one php fileindex.php(there is no directory structure). I want to be able to access anything after server.com. It will be an url structure. For example server.com/google.com, server.com/yahoo.com.au etc...An example would behttp://whois.domaintools.com/go...
location / { rewrite ^/(.*)$ /index.php?q=$1 } location = /index.php { #Do your normal php passing stuff here now }Is that what you were looking for?As an answer to your second question, you can parse the protocol in php. Nginx doesn't need to do that. To parse the url, you can use theparse_urlfunction
Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable
I'm trying to install certbot on my digital ocean droplet. I'm using ubuntu 20.04 and following instructions fromhttps://certbot.eff.org/lets-encrypt/ubuntufocal-nginx.The error occurs when I runsudo certbot --nginx. The error I get is:The nginx plugin is not working; there may be problems with your existing configurat...
you can use options to specify the path to the 'nginx' binary and conf directory (it seems that certbot expectsnginx.conffile in nginx's installation directory if you do not specify it manually)certbot certonly --nginx --nginx-ctl /usr/local/openresty/nginx/sbin/nginx --nginx-server-root /usr/local/openresty/nginx/conf
How to extend nginx config in elastic beanstalk (Amazon Linux 2)
I followed the advicehereto configure the nginx reverse proxy to allow files larger than the default 1mb. So, my code in/.platform/nginx/conf.d/prod.conflooks like this:http { client_max_body_size 30M; }However, this seems to have no effect, and nginx still registers an error when I try to upload a file larger than 1...
I has a similar issue when moving to Amazon Linux 2.Simply creating a file at.platform/nginx/conf.d/calledproxy.confwith the content below was enough for me.client_max_body_size 50M;If you go digging around the main config for nginx you'll see how this file is included into the middle of the file so there's no need to ...
Django and Nginx X-accel-redirect
I have been fumbling around with trying to protect Django's media files with no luck so far! I am simply trying to make it where ONLY admin users can access the media folder. Here is my Nginx file.server { listen 80; server_name xxxxxxxxxx; location = /favicon.ico {access_log off; log_not_found off;} l...
This is what fixed this issue thanks to @Paulo Almeida.In the nginx file I changed what I previosly had too...location /protectedMedia/ { internal; root /home/{site-name}/; }My url is...url(r'^media/', views.protectedMedia, name="protect_media"),And the View is...def protectedMedia(request): ...
Installing Gems with Bundler == Big problem
If I runbundle install, everything passes. I reboot nginx, and when I visit the site I see the passenger error with this :git://github.com/spree/spree.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)My gemfile :source 'http://rubygems.org' gem 'rails', '3.0.3' gem 'spree', :git => 'g...
That is because you also have to address where the gem location ( specifically where bundler is installed ) in your nginx start script as well.bin/start#!/bin/bash TMPDIR=/home/shadyfront/webapps/truejersey/tmp GEM_HOME=/home/shadyfront/.rvm/gems/ruby-1.8.7-p330@true /home/shadyfront/webapps/truejersey/nginx/sbin/ngin...
error Bad Gateway NGINX 502 PHP-FPM fastcgi
My boss was messing around with this page and suddenly it stopped working and started giving us a 502 Bad Gateway error. Is there anything you can see that explains why this happened? About A Deo Our Wines Tenuta A Deo - Red Tenuta A Deo - White Tenuta A Deo - Oil Popova Kula Kokino Lucca Olive Oil The Farm Villa...
A502 Bad Gatewayerror isnot caused by static HTMLlike you just displayed.The server was probably having an internal error or an error communicating with other servers - maybe there was a (temporary) overload, or another server/service was not reachable. Does it still happen when you clear your cache or use another brow...
How to setup routes with Express and NGINX?
I'm trying to configure an Express server with NGINX as a reverse proxy. NGINX to serve static files, and Express for the dynamic content.Problem : The normal root link works (website.com) , but when I navigate to (website.com/api), I get a 404 from NGINXThis is my server.js :var express = require("express"); var app =...
Try to remove this line:try_files $uri $uri/ =404;With this directive nginx tries to serve a static file (or directory), and returns404if there is no such file.
Nginx redirect URL with specific query parameter
Nginx, I am trying to permanently redirect the URLs with adeviceGET parameter (http://www.example.org/page?device=desktop) to the relative URL without this parameter (http://www.example.org/page).I did this, but it doesn't work.location { rewrite ^(.*)\?device=desktop $1 permanent; }
Each query parameter is exposed as avariable prefixed with$arg_in the configuration file. For example,devicewould become$arg_device. Using this you can make the comparison check within your location block, for example:location / { if ($arg_device = desktop) { return 301 $uri; } }
Adding custom HTTP headers to nginx X-Accel-Redirect
I am serving restricted downloads in rails usingX-Accel-Redirectwith nginx. To validate my downloads in client app, i am trying to send the checksum in the non standard HTTP headerContent-MD5to theX-Accel-Redirectrequest. But this is not working.below the rails snippet used to do the redirectionheaders['X-Accel-Redirec...
Useadd_header Content-MD5 $upstream_http_content_md5;SinceX-Accel-Redirectcauses internal redirect nginx will not send returned headers, but it will keep them in$upstream_http_...variables. So you could use them.
How to deploy php-fpm on docker container and apache/nginx on localhost (Ubuntu)
We can deploy apache and php in separate docker containers and then link them.But is there any way to install apache locally (using apt-get install apache2) and php-fpm in docker container and then link them?Thanks
you can build your own image and in the Dockerfile you canapt install ...but there is also an official image with apache + php-fpm here:https://hub.docker.com/_/phpso you dont have to. its ready to go.but i believe it could work by exposing yourphp-fpmport and configuring your apache FastCgiExternalServer to this port ...
Nginx + Php-fpm fastcgi upstream timed out
I am having issues with a long-running PHP script:<?php sleep(70); # extend 60s phpinfo();Which gets terminated every time after 60 seconds with a response504 Gateway Time-outfrom Nginx.When I inspect the Nginx errors I can see that the request times out:... [error] 1312#1312: *2023 upstream timed out (110: Connection ...
As it happens in these cases, I was actually editing a wrong configuration file that didn't get loaded by Nginx.Adding the following to the right file did the trick:fastcgi_read_timeout 600; fastcgi_send_timeout 600; fastcgi_connect_timeout 600;
Maximum recommended client_max_body_size value on Nginx
What is the maximum recommended value ofclient_max_body_sizeon Nginx for upload of large files?The web app that I'm working right now will expect uploads of max 100mb. Should I setclient_max_body_sizeto something like 150mb to upload in a single request or do the slice strategy and send chunks of 1mb to the server keep...
This is a subjective thing and use-case dependent. So the question you should ask yourself isWhat is the max size beyond which you don't want to allow an uploadthen use that.Next what mistake people make is that they just setclient_max_body_size 150M;In thenginxconfig in the server block. This is actually wrong because...
Nginx proxy and remove proxy_pass prefix
i want use nginx location proxy my applicationsnginx(ip address) : 10.255.1.10 php(10.255.1.20)Ip access:10.255.1.20/ "access ok(200)" 10.255.1.20/api "access ok(200)" 10.255.1.20/project "access ok(200)"but i use nginx proxy access 404example.com/work "access ok(200)" example.com/work/api "a...
The trailing slash does this magic, take it out from proxy_pass and it should help:server { listen 80; server_name example.com; location /work/ { proxy_pass http://10.255.8.77:8065; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For ...
How to make nginx CORS configuration work when server returns error?
I want to add CORS to my server.I have configured my nginx according to this:https://michielkalkman.com/snippets/nginx-cors-open-configuration.htmlIt seems to work fine when the server returns 200. However, if the server returns something else, like 400 when the request is wrong, or 500 if internal error, the browser ...
This has been answered before:https://serverfault.com/questions/431274/nginx-services-fails-for-cross-domain-requests-if-the-service-returns-error.add-headerdoesn't work with HTTP errors, but the optionalheaders_moremodule can be used to workaround this limitation.
React Router routes not working on nginx create-react-app
I'm using"react-router-dom": "^4.2.2".If I test onlocalhost:3000/secondit works perfectly.When I upload this on ubuntu server with nginx and I trywww.website.com, it works . When I try to usewww.website.com/secondit gives me404 not found. I'm usingcreate-react-app.app.jsclass TestRoutes extends React.Component{ con...
The answer is found in this threadReact-router and nginxWhat I had to do was modifydefaultconfiguration file in/etc/nginx/sites-available/defaultto:location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri /index.ht...
nginx service won't start after reboot AWS Linux server
A few weeks ago I configured an ec2 server on AWS and database is on RDS and I use nginx as web server. When i reboot server from the AWS console my nginx wont restart automatically. I did this usingservice nginx startcommand.Is there any way to configure nginx server, So it restarted when i reboot my ec2 instance
You may configurenginxto start automatically on system boot using below command.#chkconfig nginx onOnce you run above command, nginx will be always started whenever system boots.You may check , if service is configured to start automaticaly on system boot using below command.# chkconfig nginx --listYou may disable serv...
Verify if nginx is working correctly with Proxy Protocol locally
EnvironmentI have set up Proxy Protocol support on an AWS classic load balancer as shownherewhich redirects traffic to backendnginx(configured withModSecurity) instances.Everything works great and I can hit my websites from the open internet.Now, since my nginx configuration is done in AWSUser Data, I want to do some c...
Thanks Tarun for the detailed explanation. I discussed within the team and ended up doing creating another nginx virtual host on port 80 and using that to check ModSecurity as below.curl "http://localhost/foo?username=1'%20or%20'1'%20=%20'"`
Can Nginx do TCP load balance with SSL termination?
Due to some reason, I need to set up Nginx TCP load balance, but with SSL termination. I am not sure whether Nginx can do this. Since TCP is layer 4, SSL is layer 5, SSL pass-thru definitely work. But with SSL-termination?
Nginx can act as L3/4 balancer with stream module:https://www.nginx.com/resources/admin-guide/tcp-load-balancing/Because SSL still tcp - Nginx can proxy SSL traffic without termination.Also stream module can terminate SSL traffic, but it's optional.Example 1: TCP tunnel for IMAP over SSL without SSL terminationstream {...
Nginx - Redirect Domain Trailing Dot
How can I redirect "http://domain.com." to "http://domain.com" with Nginx?What's the recommended way of doing this? Regex or is there any other options?
The following snippet does this in a general way, without having to hard code any hostnames (useful if your server config handles requests for multiple domains). Add this inside any server definition that you need to.if ($http_host ~ "\.$" ){ rewrite ^(.*) $scheme://$host$1 permanent; }This takes advantage of the ...
Nginx set proxy_set_header if header is present
I'm using AWS CloudFront to terminate my SSL before hitting my backend, and need to distinguish this traffic from non-CloudFront traffic to set aproxy_set_headerin Nginx.I believe the best way to do this would be to check for theX-Amz-Cf-Idheader (added by CloudFront), and set theproxy_set_headerwhen it's present. Howe...
A general answer is that you can set variables inifand then use the variable. Like this:set $variable ""; if ($http_X_Amz_Cf_Id) { set $variable "somevalue"; } proxy_set_header someheader $variable;
nginx location regexp for query string
I want to redirect anything that comes directly to my server with perticuler query string to other location in same domain.If user comes tohttp://www.mydomain.com/?abc=js9sd70sI want to redirect it tohttp://www.mydomain.com/otherpath/?abc=js9sd70sthe query string?abc=js9sd70sshould be the same to new url.Please sugges...
Short answer, try this configuration:location = / { if ( $arg_abc ) { rewrite ^ /otherpath/ permanent; } }
Docker image NGINX not exposing : site cannot be reached
1.I was usingthisguide to get a nginx webserver image to run and used the commandsdocker run -p 8888:80 nginxdocker run -p 80:80 nginxI guess two or more containers got up and running but when I open localhost:8888 it shows the site cannot be reached.I have also usedthisto try and expose something on my browser. It sho...
The problem was that I was running it on VM on windows which happens with docker .So in one of thebeginner tutorialsit was mentioned that the port is forwarded to this VM port not on the windows port. (Just read the note below the hello world! browser image)So you have to find the ip address of your VM OS and paste it ...
My docker container isn't starting on localhost (0.0.0.0) on Docker for Windows (Native using Hyper-V)
I'm followingDigital Ocean's tutorialon how to start a nginx docker container (Currently on Step 4). Currently this is their output:$ docker run --name docker-nginx -p 80:80 -d nginx d3ccb73a91985651ec61231bca9f9c716f0dec807e354a29eeef2144f883a01c $ docker ps CONTAINER ID IMAGE COMMAND ...
But when I run it, this is my output (noticed the different IP of the container)Since this a Windows machine, I assume that you're usingDocker ToolboxDocker for Windows.10.0.75.2is the IP of theboot2dockervirtual machine.If you are using Windows or Mac OS, you will need some form of virtualization in order to run Doc...
What's difference between static and non-static resources?
I am primarily a front-end developer/designer, however recently, I've been exploring end to end solutions. Yesterday I finished a TODO application using the mean stack and would like to start exploring deployment options to my VPS.That being said, I've been advised to use nginx as a reverse proxy is for serving up sta...
In this case, a static resource refers to one that is not generated with code on the fly, meaning that its contents won't change from request to request.Images, JavaScript, CSS, etc., are all candidates for this. Basically, you set a large cache time for these resources, and your Nginx servers can keep a copy on disk ...
UTF-8 not working nginx
I have a self-hosted server running nginx and PHP5-fpm on a debian (raspbian wheezy) machine.My problem is UTF-8 special characters (åäö) aren't working. I've setin the head of the website. All files are encoded with utf-8 without BOM.As adviced by Fleshgrinder's answer I've addedcharset utf-8;to nginx.conf without res...
Your files must be in UTF-8 as well and the HTTP header you send is more important than the meta tag.To deliver all your content with UTF-8 encoding (HTTP header) via nginx do the following:# /etc/nginx/nginx.conf http { charset utf-8; }But the important part is that your files actually have to be encoded in UTF-8...
Add nginx as a ubuntu service stop and reload doesn't work
My nginx was compile from the source, only give the flag that--conf-path=/etc/nginx/nginx.confEverything works and I was trying to usethisservice init.d script to make nginx as a system service,Here's the script that I made only 2 minor changes:1. DAEMON=/usr/local/nginx/sbin/nginx 2.NGINX_CONF_FILE="/etc/nginx/nginx....
I've had similar problems with Nginx on Ubuntu 12.04, with nginx compile from source and init script taken from a similar source as yours.Service started well with the init file, but stop or restart didn't. In the end the cause was a different path to the pid file in the nginx.conf and the init script. Make sure they ...
Running Lua under nginx (writing a website with Lua)
As a learning exercise I've dedicated some time to picking up Lua by creating some basic apps. I've gotten it installed and running great on Natty/Ubuntu, however, I'm a bit lost as to how to get it to play nice with nginx.I've read a bit herehttp://wiki.nginx.org/HttpLuaModule#InstallationAnd cloned this repohttps://g...
The ngx_lua module is for running Lua code directly in the nginx webserver. It is possible to run entire Lua applications in this way but this is not the specific target of that module. Actually, some of the module directives specifically should not be used with long running or complex routines.You will need to recompi...
CloudFront how to setup reverse proxy on an existing distribution serving website from S3
I have a S3 bucket which hosts a website and is delivered with CloudFrontand right now I have attached the distribution to my apex root domain like - www.xyz.comSo, previously we were using Nginx to serve a static frontend from a webserver root on the same domain - www.xyz.com and had also setup a reverse proxy - www.x...
Createapi.example.comin DNS, pointing to your API.Create a second Origin in CloudFront, pointing toapi.example.com. Leave "Origin Path" blank, because it does not do what you might assume.Create a new Cache Behavior in CloudFront, with the Path Pattern of/api*. Point this to the newly-created origin.CloudFront will s...
nginx ws invalid URL prefix
First time withnginx.I have a nodejs WebSocket server listening atws://service_name:3600.I'm usingdocker-compose:version: "2" services: # stuff service_name: image: imagename ports: - 3600:3600 links: # stuff - proxy proxy: image: image-from-nginx-with-custom-co...
In nginx you still need to usehttpfor protocol in your url and notws.proxy_pass http://service_name:3600;Thewsandwssprotocol is required for browser, on server side you add below to handle the websockets over httpproxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
UDP forwarding with nginx
I have a main syslog server that is receiving syslog from several sources, and I want to send those logs to a Graylog cluster. To help the cluster keep up (on some slow VMs), I need to be able to load balance the messages to Graylog, as sometimes they come in massive chunks from the endpoints (some send 5k logs in bur...
So this did seem to be the solution (in my note above).If using my example from above, you want this to look like:stream { server { listen 11016 udp; proxy_pass juniper_close_stream_backend; proxy_responses 0; } }This tells nginx not to expect a response, which it shouldn't need fr...
Does renewing SSL certificate require re-issuing the cert?
I have an SSL certificate that I am using to secure port 443 (HTTPS) on my nginx server running on Ubuntu for about 10 months now.When I bought the cert, I got it for one year, so I have about 2 more months with this certificate. My question is: "When I renew this cert, Will I just need to pay for renewal? or will I h...
It's not possible to extend the expiration of an existing certificate once issued. The only way is to issue a new certificate.Most certificate authorities offers a "renewal" concept, which provides some advantages compared to a new purchase. For example, you can renew in advance to the certificate expiration, and they ...
Injecting app level username/userid into nginx/Apache log
Is there a way to inject an application level username or id (in this case, the django username or id) into the Apache or ngnix log? Note that I'm not asking about the HTTP auth username.
We do something like this, only we tell Apache to store the the Django sessionid cookie.LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{sessionid}C" withsession CustomLog logs/example.com-access_log withsessionIt's sort of a two-step process to map the sessionid to the user, but it's easy to i...
How do I configure my Nginx server to work with a React app in a subfolder?
I am trying to deploy a React application in a subfolder on my Nginx server.The location of this React app is structured like: www.example.com/reactApp.I tried to set up my current nginx.conf like so:server { ..other configs.. location /reactApp { root /var/www; index reactApp/index.html; ...
The last component of thetry_filesstatement should be a URI. Assuming that yourindex.htmlfile is located under the/var/www/reactAppsubfolder, you should use:location /reactApp { root /var/www; index index.html; try_files $uri $uri/ /reactApp/index.html; }Seethis documentfor more.
Absolute path for error_page in nginx?
Is there a way I can set an absolute path for nginx error_pages? Not absolute as inhttp://, but absolute as in/usr/var/nginx/errors/500.html.
Sure you can but in an indirect way:error_page 500 /500.html; location = /500.html { root /usr/var/nginx/errors; allow all; internal; }seehttp://wiki.nginx.org/HttpCoreModule#error_page
nginx + passenger + rails - 403 forbidden error
I have install Nginx server and configured all needed stuff, but currently I'm having error with 403 forbidden error. Log says:2010/12/28 17:38:59 [error] 28664#0: *27 directory index of "/home/appuser/test_app" is forbidden, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET / HTTP/1.1", host: "xxx.xxx.xxx.xxx"...
change/home/appuser/test_appto/home/appuser/test_app/public
how to add --auth for mongodb image when using docker-compose?
I'm using docker-compose to run my project created by node,mongodb,nginx;and I have build the project usingdocker buildand then I usedocker up -d nginxto start my project. but I haven't found the config to run mongodb image with '--auth', so how to add '--auth' when compose start the mongodb?here is my docker-compose.y...
Supply acommandto the container including the--authoption.mongodb: image: mongo:latest expose: - "27017" volumes: - "/home/open/mymongo:/data/db" command: mongod --authThe latest mongo containers come with"root" auth initialisation via environment variablestoo, modelled on the postgres s...
Php7 and php5 on fedora at the same time
How can I setup PHP5 and PHP7 on one Fedora system?As I see, PHP in fedora is not one directory, it's spread in OS.On Windows systems, PHP is one folder, so I can just rename it when I need a specific version of PHP. What about Fedora?Maybe there are some useful links but I haven't found them.Also, it will bephp5+apach...
I suggest you to install remi repository. I assume you use fedora 23.sudo dnf install http://rpms.remirepo.net/fedora/remi-release-23.rpmAfter installing remi repository, you have to edit/etc/yum.repos.d/remi.repofile and enable it. Finally you can install various versions of php. for example:sudo dnf install php70-ph...
how to nginx configuration updates without having to reload or restart nginx
I want Nginx to update configuration file without reloading or restarting Nginx. It seem API or anything (http://nginx.com/products/on-the-fly-reconfiguration/).
On Ubuntu or Debian it's as simple as using thereloadargument:service nginx reloadThe official way is to send SIGHUP:kill -HUP $(ps -ef | grep nginx | grep master | awk '{print $2}')The above command will get the process ID of the nginx master process and send a SIGHUP signal to it.See theControlling Nginxdocumentation...
Swagger UI not working as expected while service behind Nginx reverse-proxy
I use swagger-ui-express package(https://github.com/scottie1984/swagger-ui-express) (Node.js) and work fine with this config:const swaggerUi = require('swagger-ui-express'); const swaggerDocument = require('./swagger.json'); app.use('/api-docs',swaggerUi.serve, swaggerUi.setup(swaggerDocument));when directly got to /ap...
The problem was for theswagger-ui-expressmiddleware that redirect user to host/api-docs and don't use the prefix of path, so I solved this problem with a trick I use middleware with this path :const swaggerUi = require('swagger-ui-express'); const swaggerDocument = require('./swagger.json'); app.use('/app-prefix/api-do...
Deploying Angular app in a different folder than root folder
New to Angular. App works fine if deployed innginx/var/www/mydomain.com/html. But I want to deploy it in/var/www/mydomain.com/html/myappfolder. I setupnginx available sitesto this folder andindex.htmlworks fine. But relative paths in Angular app (e.g., images/mypic.png) being attempted to be retrieved from/var/www/...
###Onangular.json>build>optionsconfiguration add this line with target sub directory"baseHref" : "/v2/",**like this **"build": { "builder": "@angular-devkit/build-angular:browser", "options": { "baseHref" : "/v2/",
How to get current worker connections being used by nginx?
Nginx.conf, looks like thisuser www-data; worker_processes 4; pid /run/nginx.pid;events { worker_connections 768; # multi_accept on; }The commandulimit -ngives the number of worker connections available, I want the number which is currently being used by nginx.
Thengx_http_stub_status_modulemodule provides access to basic status information.location /basic_status { stub_status; }This configuration creates a simple web page with basic status data which may look like as follows:Active connections: 291 server accepts handled requests 16630948 16630948 31070465 Reading: 6 ...
phpredis errors Class Redis not found in Linux
I met a weied problem when installing phpredis bycd phpredis && ./configure && make && make installafter that, I addextension=redis.sointo php.ini.I can get an OK by runningphp -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"BUT when running http:127.0.0.1, nginx throw a error " Fatal error: Class 'Redis' not fo...
The command line probably does not use the same php.ini file than the web server. Usephpinfo();to know which configuration file is loaded in both cases and then declare your extension in the ini file used by your web server.
uWSGI logging not working if log file is removed
My goal is rotating the logs generated by uWSGI, but when the original log file is deleted (after compression) it is not re-created again.So I thought that the app needs a graceful restart of the master process after the file is deleted. I use this RESTART script:/home/tester/uwsgi-18 --reload /var/run/uwsgi/my_app_tes...
You have various approaches:1) copytruncate in the logrotate script, this will work reliably and without the help of uWSGI2) uWSGI log rotation:--log-maxsize will automatically rotate logs when a specific size is reached3) classic logrotation + log reloading, just add--log-masterand trigger log reloading withhttp://uws...
Restricting access to static files in Django/Nginx
I am building a system that allows users to generate a documents and then download them. The documents are PDFs (not that it matters for the sake of this question) and when they are generated I store them on my local file system that the web server is running on with uuid file namesc7d43358-7532-4812-b828-b10b26694f0f....
How about enforcinguser==ownerat the view level, preventing access to the files, storing them as FileFields, and only retrieving the file if that condition is met.e.g. You could use the@login_requireddecoratoron the view to allow access only if logged in. This could be refined usingrequest.userto check against the owne...
How to work with Puppet dependencies when installing Nginx 1.0.5 on Ubuntu 11.04
I'm new to Puppet and have a question about working with dependencies.I'm using Puppet to install Nginx 1.0.5 on Ubuntu 11.04. It requires adding a new apt repository since natty normally comes with Nginx 0.8. At the commandline, the install goes like this:# apt-get install python-software-properties # add-apt-reposito...
Here are two approaches for fixing this:1)exec { "add-apt-repository ppa:nginx/stable && apt-get update": alias => "nginx_repository", require => Package["python-software-properties"], creates => "/etc/apt/sources.list.d/nginx-stable-natty.list", }That will tell the exec to only run if that file doesn't exi...
How can I keep a Passenger Standalone up even after a restart?
I have a few apps running rails 3 on ruby 1.9.2 and deployed on a Ubuntu 10.04 LTS machine using nginx + passenger. Now, I need to add a new app that runs on ruby 1.8.7 (REE) and Rails 2. I accomplished to do that with RVM, Passenger Standalone and a reverse proxy.The problem is that, every time I have to restart the s...
Here is what I got working. Using Upstart (Ubuntu 10.04) to start the passenger daemonMy environment uses rvm with ruby 1.9.2 and apache and my rails app is deployed via capistrano# Upstart: /etc/init/service_name.conf description "start passenger stand-alone" author "Me <[email protected]>" # Stanzas # # Stanzas cont...
Activating Gunicorn through virtualenv with Supervisor for Flask Application
I'm trying to deploy a flask application to an ec2 instance using (1) nginx (2) gunicorn, (3) git, and (4) supervisor. I've set up nginx, git, gunicorn, but I've having trouble writing the supervisor script.I'm unable to get supervisor to launch gunicorn within the context of the virtualenv.When I rungunicorn run:appou...
You were on the right track, but it's simpler than you were making it. To run a Flask app named run with entry point app via gunicorn under supervisor with the path you gave:/etc/supervisor/conf.d/run.conf[program:run] command = /var/www/sitename/env/bin/gunicorn run:app -b localhost:8000 directory = /var/www/sitename ...
Why does ASP.NET 5 on Linux require kestrel?
I am trying to understand the entire web/framework/application stack when installing ASP.NET 5 on Linux.All the instructions I have read, includingthis onehaven't really answered my question:Why can't Nginx server workwithoutKestrel like here:http://www.mono-project.com/docs/web/fastcgi/nginx/?Or am I way off. I'm tryi...
ASP.NET Core(ASP.Net 5) doesn't requireKestrel!You're right,Kestrelis just a simple HTTP server with a small set of features. You can runASP.NET CorewithoutKestrelonLinuxorMac, but you must either have an HTTP server or a fastCGI server.Nginxis used as a reverse proxy for static contents in general and you can also en...