Questions tagged [nginx]
Nginx ("eNgine x") is a lightweight, high-performance HTTP server, reverse proxy, TCP stream proxy and mail proxy, released under a BSD-like license.
17,223
questions
70
votes
3
answers
75k
views
Is the PHP option 'cgi.fix_pathinfo' really dangerous with Nginx + PHP-FPM?
There has been a lot of talking about a security issue relative to the cgi.fix_pathinfo PHP option used with Nginx (usually PHP-FPM, fast CGI).
As a result, the default nginx configuration file used ...
68
votes
4
answers
99k
views
best way to debug nginx rewrite rules in config file?
I have a bunch of rewrite rules that I have to port from apache to nginx.
It's a rather painful process because I'm not able to see if my rewrite rules and "if" conditions are working as I want them ...
68
votes
13
answers
358k
views
104: Connection reset by peer while reading response header from upstream (Nginx)
I have a server which was working ok until 3rd Oct 2013 at 10:50am when it began to intermittently return "502 Bad Gateway" errors to the client.
Approximately 4 out of 5 browser requests succeed but ...
67
votes
2
answers
109k
views
Nginx location regex doesn't work with proxy pass
I'm trying to get these 2 location directives working in Nginx but I'm getting some errors back when booting Nginx.
location ~ ^/smx/(test|production) {
proxy_pass http://localhost:8181/...
66
votes
4
answers
69k
views
Suspicious symbols on nginx config
I have the following nginx config, e.g.
server {
listen 80;
server_name example.com
allow 127.0.0.0/8;
When I restart, it warn me:
Restarting nginx: nginx: [warn] server ...
65
votes
4
answers
353k
views
How do I change the NGINX user?
I have a PHP script that creates a directory and outputs an image to the directory. This was working just fine under Apache but we recently decided to switch to NGINX to make more use of our limited ...
64
votes
5
answers
122k
views
Optimal value for Nginx worker_connections
Nginx worker_connections "sets the maximum number of simultaneous connections that can be opened by a worker process. This number includes all connections (e.g. connections with proxied servers, among ...
64
votes
3
answers
243k
views
nginx set variable in location
I am trying to optimize my nginx configs, so it would be possible to set one variable, and all location paths would update automatically. I have four lines in question:
server_name php.domain.com;
...
64
votes
1
answer
105k
views
Server Aliases on NGINX
I'm moving a site to a new server running on NGINX. The old site's Apache2 VirtualHost has ServerAlias configured that I want to replicate in the NGINX configuration.
From what I've read on the ...
62
votes
4
answers
167k
views
How to use nginx to proxy to a host requiring authentication?
How can I setup an nginx proxy_pass directive that will also include HTTP Basic authentication information sent to the proxy host?
This is an example of the URL I need to proxy to:
http://username:...
62
votes
2
answers
53k
views
How can I configure nginx locations to share common configuration options?
How can i configure a shared config block for a set of locations?
location / {
proxy_pass http://127.0.0.1:9000/;
proxy_redirect off;
...
60
votes
4
answers
205k
views
nginx without server_name and using only static ip address?
this is my first web app deployment and am running into all sorts of issues.
I am currently going for a nginx + gunicorn implementation for the Django app, but mostly this question relates to nginx ...
58
votes
4
answers
82k
views
What is the best nginx compression gzip level?
I'm using nginx reverse proxy cache with gzip enabled. However, I got some problems from Android applications HTTP-requests to my Rails JSON web service. It seems when I turn off reverse proxy cache, ...
57
votes
4
answers
102k
views
nginx proxy pass redirects ignore port
So I'm setting up a virtual path when pointing at a node.js app in my nginx conf. the relevant section looks like so:
location /app {
rewrite /app/(.*) /$1 break;
proxy_pass http://localhost:...
57
votes
2
answers
85k
views
Lets Encrypt with an nginx reverse proxy
Introduction
I have a dev server (currently running Ubuntu 14.04 LTS), which I have been using for a while now for hosting various development tools on different ports. Because the ports can be hard ...
57
votes
3
answers
125k
views
Configure Nginx as reverse proxy with upstream SSL
I try to configure an Nginx server as a reverse proxy so the https requests it receives from clients are forwarded to the upstream server via https as well.
Here's the configuration that I use:
http ...
55
votes
5
answers
26k
views
Ordering: 1. nginx 2. varnish 3. haproxy 4. webserver?
I've seen people recommend combining all of these in a flow, but they seem to have lots of overlapping features so I'd like to dig in to why you might want to pass through 3 different programs before ...
55
votes
4
answers
148k
views
how to restrict access to directory and subdirs
I need to restrict access to any files or subdirs in direstory "testdir". My conf:
...
location ~* ^.+\.(jpg|txt)$ {
root /var/www/site;
}
location /testdir {
deny all;
...
55
votes
1
answer
100k
views
nginx: no permission to bind port 8090 but it binds to 80 and 8080
I'm struggling with some strange permission related behavior: when I configure nginx to listen to port 8080 everything works as expected, but when I use any other port I get something like
2014/01/10 ...
55
votes
3
answers
184k
views
Proxy HTTPS requests to a HTTP backend with NGINX
I have nginx configured to be my externally visible webserver which talks to a backend over HTTP.
The scenario I want to achieve is:
Client makes HTTP request to nginx which is redirect to the same ...
54
votes
5
answers
147k
views
How to disable Nginx logging?
I have the following in config file
server {
listen 80;
server_name _;
access_log /var/log/nginx/access.log main;
...
server {
listen 80;
server_name example....
54
votes
4
answers
84k
views
How to enable correct charset HTTP-header in NGINX
What is the right way to enable correct charset headers in NGINX?
I'm analyzing my website with Google Page Speed. It says that I should specify the charset of HTML files in HTTP-headers. What is the ...
53
votes
1
answer
133k
views
How to resolve the gunicorn critical worker timeout error?
I have used nginx and gunicorn to host my website in two servers,
Both server have same versions of packages and website is successfully hosted,
But in one of my server gunicorn always gets timeout ...
52
votes
1
answer
238k
views
nginx server directive is not allowed here
I know there are dupes of this out there, but I can't seem to solve this in my situation.
I'm following an article on setting up nginx as reverse proxy with apache.
And I get this error:
nginx: [...
50
votes
3
answers
78k
views
Use HTTP/2.0 between nginx reverse-proxy and backend webserver
I use nginx as a reverse-ssl-proxy in front of a backend webserver that is capable of doing HTTP/2.0.
I noticed that nginx proxies the requests to the backend server via HTTP/1.1 rather than HTTP/2.0....
49
votes
4
answers
114k
views
Installing optional Nginx modules with apt-get
I currently have Nginx installed via the instructions on the Nginx site:
nginx=stable
sudo su -
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get install
I have configured Nginx and it has ...
49
votes
3
answers
123k
views
Can nginx location blocks match a URL query string?
Can nginx location blocks match a URL query string?
For example, what location block might match HTTP GET request
GET /git/sample-repository/info/refs?service=git-receive-pack HTTP/1.1
49
votes
2
answers
29k
views
What does the at-sign "@" mean in nginx location blocks?
I've encountered a few questions and answers on here that use this syntax:
location @default {
# ...
}
location /somewhere {
try_files $uri @default;
}
I've searched high and low on the ...
49
votes
3
answers
22k
views
Why is setting Nginx as a reverse proxy a good idea?
I have a Django site running on Gunicorn with a reverse proxy through Nginx.
Isn't Nginx just an extra unnecessary overhead?
How does adding that on top of Gunicorn help?
48
votes
6
answers
88k
views
Permission denied while reading upstream
We have deployed our rails application on on Nginx and passenger. Intermittently, pages of application get loaded partially. There is no error in application log, but the Nginx error log shows the ...
48
votes
2
answers
118k
views
How to quick and easy remove part of an URL in Nginx with HttpRewriteModule?
I know about the HttpRewriteModule, but I don't really know how to handle regex and I would need to redirect all URLs within a certain directory to another, specifically:
From: example.com/component/...
48
votes
2
answers
78k
views
nginx split large configuration file
My nginx default configuration file is becoming huge. I'd like to split it to smaller config files, each including only one, maximum 4 locations to each file, so that I can enable/disable them quickly....
48
votes
5
answers
65k
views
Is there a cloud-based reverse proxy solution in AWS? [closed]
The system
I have an API deployed on EC2 machines on AWS. Incoming HTTPS requests are passed to an elastic load balancer. The load balancer handles the SSL, and passes the request to an Nginx server, ...
47
votes
9
answers
191k
views
Nginx fails to stop and nginx.pid is missing
I want to stop Nginx but it fails like this.
$ sudo service nginx stop
Stopping nginx: [FAILED]
And nginx.conf that defines place of nginx.pid have a line.
#...
47
votes
5
answers
49k
views
User per virtual host in Nginx
Is it possible in nginx configure different user per virtual host?
Something like
server {
user myprojectuser myprojectgroup;
...
}
46
votes
15
answers
41k
views
NGinx Best Practices
What best practices do you use while using NGinx?
46
votes
2
answers
71k
views
Nginx "Default" Server? [duplicate]
I have an Nginx with a number of enabled server blocks. Each server answers to 1 canonical domain and may forward 1 or more to that canonical URL. I have at least one server (haven't checked all of ...
46
votes
4
answers
53k
views
Setting Nginx to catch all unhandled vhosts
If I already have a bunch of virtualhosts, how can I create a virtual host to handle requests that don't match any of the virtualhosts? (i.e. access by IP, another domain linking to IP, .etc .etc)
45
votes
1
answer
47k
views
For Server-Sent Events (SSE) what Nginx proxy configuration is appropriate?
I've read a bunch of different questions on what Nginx configuration is appropriate for SSE and came up with some confusing results regarding what settings to use:
https://stackoverflow.com/questions/...
45
votes
5
answers
49k
views
Nginx vs Apache as reverse proxy, which one to choose
this kind of question maybe has been asked here
but I couldn't find any that really match my question.
Heard that nginx performance is quite impressive,
but Apache has more docs, community(read:expert)...
45
votes
1
answer
48k
views
Understanding the nginx proxy_cache_path directive
Suppose I have this nginx config file
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=myCache:8m max_size=100m inactive=1h;
What does the keys_zone=myCache:8m mean? There's not much said to ...
45
votes
1
answer
22k
views
nginx name-based virtual hosts on IPv6
I have an nginx server serving up nearly half a dozen different websites. It's running on a Linode that just got IPv6 native support (Dallas data center), and I'm trying to configure most of my sites ...
44
votes
6
answers
118k
views
Increase PHP-FPM's max upload/post size
I'm running php5-fpm under Nginx on Ubuntu 14.04. I want to increase the max upload size.
I have edited my /etc/php5/fpm/php.ini to have the following lines defined as below:
upload_max_filesize = ...
44
votes
3
answers
86k
views
How to totally remove a certbot-created SSL certificate?
I use Ubuntu 16.04 with Nginx and I've installed Nginx Certbot on my operating system (Ubuntu 16.04) with:
apt-get update -y
add-apt-repository ppa:certbot/certbot -y
apt-get update -y
apt-get ...
44
votes
4
answers
85k
views
How can I debug nginx further than the error log?
I'm currently receiving a fairly large HTTP flood right now, and it's causing my nginx reverse proxy to produce a 502 Bad Gateway.
I have a frontend server running nginx as a proxy to my backend ...
44
votes
2
answers
26k
views
Setting ssl_prefer_server_ciphers directive in nginx config
This question is about setting the correct value of ssl_prefer_server_ciphers while configuring nginx.
According to a fairly typical config suggested by Mozilla, the value should be off (source: ...
44
votes
2
answers
63k
views
Merging variable with string in config file
I the have following setup in my conf file
upload_set_form_field $upload_field_name.name "$upload_file_name";
But I want change chosen param name to:
upload_set_form_field ($upload_field_name+"[...
44
votes
3
answers
171k
views
nginx as reverse proxy with upstream SSL
I'm building a proxy for an internal API to allow clients to connect without having to have the self-signed certificates installed.
Clients (built, owned and used only internally) will connect over ...
44
votes
4
answers
146k
views
Forward Custom Header from Nginx Reverse Proxy
I have an nginx web server acting as a reverse proxy to forward requests on to Apache for additional handling (I'm begging you not to ask why). I have a request to which I'm trying to attach a custom ...
43
votes
2
answers
154k
views
Nginx: location regex for multiple paths
I have two locations in nginx config that work:
location ^~ /media/ {
proxy_pass http://backend.example.com;
}
location ^~ /static/ {
proxy_pass http://backend.example.com;
}
How can I combine ...