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
152
votes
13 answers

How to set up Nginx as a caching reverse proxy?

I heard recently that Nginx has added caching to its reverse proxy feature. I looked around but couldn't find much info about it. I want to set up Nginx as a caching reverse proxy in front of Apache/Django: to have Nginx proxy requests for some (but…
Continuation
  • 3,080
  • 5
  • 30
  • 38
148
votes
7 answers

Make nginx to pass hostname of the upstream when reverseproxying

I run several docker containers with hostnames: web1.local web2.local web3.local Routing to these done based on hostname by nginx. I have a proxy in front of this setup (on different machine connected to internet) where I define upstream as: …
pavel_karoukin
  • 1,611
  • 2
  • 11
  • 5
145
votes
2 answers

Is it possible to make Nginx listen to different ports?

I created one Nginx with one Linux Azure VM, is it possible to make nginx listen to different ports so that when I change the port number, the content would be different. I found there would be a collision if I created two or more ports related to…
billcyz
  • 1,720
  • 3
  • 13
  • 16
140
votes
8 answers

connect() failed (111: Connection refused) while connecting to upstream

I'm experiencing 502 Gateway errors when accessing a PHP file in a directory (http://example.com/dev/index.php). The logs simply says this: 2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to…
MacMac
  • 2,061
  • 10
  • 31
  • 38
132
votes
12 answers

Can I hide all server / os info?

I don't want anyone to be able to detect that I'm using NGINX or even Ubuntu from the internet. There are tools out there (such as BuiltWith) which scan servers to detect what tools they're using. Also, some cracking tools might help with deteting.…
orokusaki
  • 2,763
  • 4
  • 32
  • 43
125
votes
4 answers

Nginx: How do I forward an HTTP request to another port?

What I want to do is: When someone visits http://localhost/route/abc the server responds exactly the same as http://localhost:9000/abc Now I configure my Nginx server like this: location /route { proxy_pass http://127.0.0.1:9000; } The HTTP…
WoooHaaaa
  • 1,605
  • 4
  • 15
  • 13
121
votes
16 answers

Nginx 1 FastCGI sent in stderr: “Primary script unknown”

My first time using Nginx, but I am more than familiar with Apache and Linux. I am using an existing project and when ever I am trying to see the index.php I get a 404 File not found. Here is the access.log entry: 2013/06/19 16:23:23 [error] 2216#0:…
We0
  • 1,409
  • 2
  • 11
  • 11
118
votes
4 answers

How to disable timeout for nginx?

On a local development machine, I have a nginx reverse proxy like so: server { listen 80; server_name myvirtualhost1.local; location / { proxy_pass http://127.0.0.1:8080; } server { listen 80; server_name myvirtualhost2.local; …
k0pernikus
  • 4,170
  • 4
  • 17
  • 17
116
votes
2 answers

How does try_files work?

I looked at the nginx documentation and it still confuses me utterly. How does try_files work? Here is what the documentation says: From NginxHttpCoreModule try_files syntax: try_files path1 [path2] uri default: none context: server,…
user274
112
votes
3 answers

nginx - client request body is buffered to a temporary file

I get the following error in my log files every time I try to upload a large file. a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001 Although the file uploads successfully, I always get the above error. I…
Abs
  • 1,559
  • 5
  • 19
  • 32
112
votes
8 answers

What does this nginx error "rewrite or internal redirection cycle" mean?

tail -f /var/log/nginx/error.log 2013/05/04 23:43:35 [error] 733#0: *3662 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: _, request: "GET /robots.txt HTTP/1.1", host:…
pavs-maha
  • 1,123
  • 2
  • 7
  • 5
112
votes
8 answers

Setting the "Expires" HTTP header for static content served from Nginx?

I'm using nginx to server my static content, is there a way that I can set the expires headers for every file that meets a specific rule? For example can I set the expires header for all files that have an extension of '.css'?
Unkwntech
  • 1,760
  • 4
  • 19
  • 24
112
votes
7 answers

How to restart nginx?

For me, I run "killall nginx" and start it by "sbin/nginx", anyone has a better restart script? BTW: I install nginx from source, i do not find 'service nginx' command or /etc/init.d/nginx
larry
  • 4,037
  • 9
  • 36
  • 42
110
votes
5 answers

Do you need separate IPv4 and IPv6 listen directives in nginx?

I've seen various config examples for handling dual-stack IPv4 and IPv6 virtual hosts on nginx. Many suggest this pattern: listen 80; listen [::]:80 ipv6only=on; As far as I can see, this achieves exactly the same thing as: listen [::]:80…
Synchro
  • 3,148
  • 6
  • 27
  • 38
106
votes
2 answers

an upstream response is buffered to a temporary file

I have a rather large and slow (complex data, complex frontend) web application build in RoR and served by Puma with nginx as reverse proxy. Looking at the nginx error log, I see quite a few entries like: 2014/04/08 09:46:08 [warn] 20058#0: *819237…
ngw
  • 1,261
  • 3
  • 13
  • 15