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.

Nginx is a web server and mail proxy known for its high performance and small resource footprint. It is used in many places as a replacement to Apache and also as a front end server to static content or reverse proxying. Nginx is developed under a BSD-like license by Kazakhstani developer Igor Sysoev.

Nginx comes with diverse modules that enable it to perform various different tasks such as load balancing, URL rewriting, request rate limiting, content compression, raw TCP proxying and integration with tools like memcached or scripting languages like Lua.

Nginx is being used by some of the worlds busiest sites like WordPress, Sourceforge, Github and Reddit. Its market share has been raising from 7% in 2008 to over 30% as of June 2016 according to W3techs statistics.

After nine years of development, Nginx 1.0 stable was released on April 2011.

17017 questions
78
votes
4 answers

nginx real_ip_header and X-Forwarded-For seems wrong

The wikipedia description of the HTTP header X-Forwarded-For is: X-Forwarded-For: client1, proxy1, proxy2, ... The nginx documentation for the directive real_ip_header reads, in part: This directive sets the name of the header used for…
Kirk Woll
  • 883
  • 1
  • 7
  • 7
78
votes
11 answers

Remove "www" and redirect to "https" with nginx

I want to create a rule in nginx that does two things: Removes the "www." from the request URI Redirects to "https" if the request URI is "http" There are plenty of examples of how to do each of those things individually, but I can't figure out a…
Devin
  • 903
  • 1
  • 8
  • 8
75
votes
11 answers

How can I create a location in nginx that works with AND without a trailing slash?

Right now I have this config: location ~ ^/phpmyadmin/(.*)$ { alias /home/phpmyadmin/$1; } However, if I visit www.mysite.com/phpmyadmin (note the lack of trailing slash), it won't find what I'm looking for a 404. I assume because I don't…
Rob
  • 2,393
  • 9
  • 33
  • 52
74
votes
5 answers

Dump nginx config from running process?

Apparently, I shouldn't have spent sleepless night trying to debug an application. I wanted to restart my nginx and discovered that its config file is empty. I don't remember truncating it, but fat fingers and reduced attention probably played their…
Sergio Tulentsev
  • 843
  • 1
  • 9
  • 9
72
votes
3 answers

nginx: Log complete request / response with all headers?

We have an application server that sometimes hangs. We suspect it is due to a bad request from a client. Can nginx log the complete request/response (like fiddler captures) to files, so we can see the requests that were sent before the hang? (We…
Jonesome Reinstate Monica
  • 5,445
  • 10
  • 56
  • 82
68
votes
3 answers

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 to say: # NOTE: You should have…
Totor
  • 2,916
  • 3
  • 23
  • 31
67
votes
2 answers

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/cxf; } location ~ ^/es/(test|production)…
Niels
  • 821
  • 3
  • 9
  • 8
65
votes
13 answers

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 about 1 in 5 fail with a 502. The nginx error log…
Nigel Alderton
  • 992
  • 3
  • 9
  • 19
65
votes
4 answers

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 to. Apache did have debugging for its rewrite…
Jiho Kang
  • 1,047
  • 2
  • 10
  • 8
64
votes
4 answers

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 name "127.0.0.0/8" has suspicious symbols in…
Ryan
  • 5,831
  • 24
  • 72
  • 91
63
votes
1 answer

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 NGINX Docs this seems to be simply achieved with…
Holly
  • 1,027
  • 5
  • 14
  • 25
62
votes
2 answers

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; root /srv/web/vhosts/php/web; error_log…
Bogdan Kuštan
  • 723
  • 1
  • 5
  • 6
61
votes
5 answers

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 others), not only connections with clients.…
Aarti
  • 689
  • 1
  • 7
  • 6
61
votes
4 answers

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 RAM. I'm using the PHP mkdir() command to create…
David
  • 845
  • 3
  • 8
  • 10
61
votes
4 answers

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:password@192.168.0.5/export?uuid=1234567890 The…
bwizzy
  • 1,295
  • 4
  • 14
  • 17