nginx (pronounced "engine-x") is a lightweight, high-performance Web server and reverse proxy as well as IMAP/POP3 proxy server.

learn more… | top users | synonyms

171
votes
5answers
128k views

In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?

I want to rewrite all http requests on my web server to be https requests, I started with the following: server { listen 80; location / { rewrite ^(.*) https://mysite.com$1 ...
104
votes
12answers
105k views

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 ...
84
votes
2answers
29k views

How can I see which flags Nginx was compiled with?

How can I check what modules have been added to an nginx installation?
80
votes
5answers
24k views

nginx HTTPS serving with same config as HTTP

Is there a way to share configuration directives across two nginx server {} blocks? I'd like to avoid duplicating the rules, as my site's HTTPS and HTTP content are served with the exact same config. ...
78
votes
7answers
58k views

How to force or redirect to SSL in nginx?

I have a signup page on a subdomain like: https://signup.mysite.com It should only be accessible via HTTPS but I'm worried people might somehow stumble upon it via HTTP and get a 404. My ...
43
votes
1answer
9k views

Why do I need Nginx and something like Gunicorn?

Im looking for a overly simplified answer for the following question. Im trying to build a foundational understanding of how Nginx works along side something like GUnicorn. Do I need both Nginx and ...
42
votes
1answer
38k views

How do I add Access-Control-Allow-Origin in NGINX?

How do I set the Access-Control-Allow-Origin header so I can use web-fonts from my subdomain on my main domain? Notes: You'll find examples of this and other headers for most HTTP servers in the ...
36
votes
3answers
23k views

Disable caching when serving static files with Nginx (for development)

We are using Nginx to serve static files on a development platform. As it is a development platform, we'd like to disable caching so that each change is propagated to the server. The configuration of ...
35
votes
7answers
67k views

How do you restart php-fpm?

I need to reload my php.ini and there's nothing in the help dialog about restarting it.
31
votes
4answers
17k views

How to make modification take affect without restart nginx?

Apache has a graceful option which can scan for modification in http.conf without restarting apache,what about nginx?
29
votes
5answers
34k views

Setting expires headers 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 ...
26
votes
7answers
10k views

Why is Nginx so fast?

How does a site like rambler serve dynamic content so fast? Even faster than Yahoo (which has a server in my country- SE Asia; rambler does not). Is this purely Nginx’s capability? Where should I ...
25
votes
3answers
7k views

Apache vs Nginx

I have been investigating the differences between Apache and Nginx recently and am confused about which I should choose. I have done some searching but there is no definitive comparison between the ...
25
votes
8answers
18k views

My server is still vulnerable to heartbleed even after I update OpenSSL

I have an Ubuntu 12.04 server. I have updated the OpenSSL package in order to fix the heartbleed vulnerability. But I am still vulnerable even, even though I have restarted the web server, and even ...
25
votes
5answers
30k views

Configure nginx for jboss/tomcat

In order to pass traffic to JBoss/TomCat on port 80 using Apache we used to install and configure mod_jk. Is there an equivalent for nginx? Basically want all port 80 traffic to be passed to jboss.
22
votes
2answers
30k views

How to reduce number of sockets in TIME_WAIT?

Ubuntu Server 10.04.1 x86 I've got a machine with a FCGI HTTP service behind nginx, that serves a lot of small HTTP requests to a lot of different clients. (About 230 requests per second in the peak ...
20
votes
2answers
9k views

Is Varnish with nginx better than just using nginx? [closed]

I see a lot of talk about using nginx with Varnish and I do not understand why. Isn't nginx enough? Nginx has SSI, has reverse proxy cache, is lightweight, has SSL, can work with cgi, fpm, etc. ...
20
votes
1answer
6k 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 ...
19
votes
4answers
11k 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 ...
19
votes
1answer
2k views

Recommended Nginx + WSGI Configurations

Please explain pros/cons when using the different Nginx WSGI interfaces? Please explain in detail what differentiates each configuration? Which configuration should scale the best? If relevant, what ...
18
votes
10answers
7k views

Shellshock: How do I know if my server is compromised + suspicious files to look out for

Three questions which I hope someone can help answer: How do I know if my server is already compromised due to the Shellshock bug ? If it was compromised, is there a particular folder where I should ...
18
votes
4answers
17k views

Which is best for Django? Lighttpd or Nginx? Or maybe something else? [closed]

Which of Lighttpd and Nginx is, basing on your experience, better suited for Django? I've used both and can hardly notice any difference at all, they just work fine... Are there any use cases when one ...
18
votes
2answers
9k views

How can I use environment variables in Nginx.conf

[Cross-posted and edited down from http://stackoverflow.com/questions/21933955 as it was considered too sysadmin-like for StackOverflow.] I have a docker container running Nginx, that links to ...
17
votes
3answers
14k 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 ...
17
votes
1answer
785 views

nginx upload progress combined with normal request

I have a good virtual host for nginx that works well without using the nginx upload module. When I add upload progress into this my upload request. How can I solve this? i need to upload my files ...
16
votes
4answers
39k views

nginx support for .htaccess / rewrite rules? Differences from Apache?

I've been working with Apache http servers for quite some time, and finally making the move to static-content servers alongside the others dynamic-content machines. I was wondering, does nginx ...
16
votes
4answers
22k views

number of nginx worker processes

I'm setting up nginx to serve a Drupal install, and I seem to find conflicting information on the nginx worker processes setting. One site says you need two, one says you need five, one says one per ...
15
votes
1answer
957 views

How to mitigate POODLE but keep SSLv3 support for old clients

How do I mitigate the POODLE attack, but still keep support for old clients such as IE6 on Windows XP or an e-mail client. I've noticed that google does this: ...
15
votes
4answers
55k views

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

I'm experiencing 502 gateway errors when accessing a PHP file in a directory (http://domain.com/dev/index.php), the logs simply says this: 2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed ...
15
votes
1answer
3k 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?
15
votes
4answers
4k views

Apache or NGINX for PHP?

I've read quite a bit on the major benefits to running NGINX over Apache for serving static files. However, I have never seen an article talking about Apache vs NGINX for serving PHP pages. Question: ...
14
votes
7answers
58k views

Nginx + php-fpm “504 Gateway Time-out” error with almost zero load (on a test-server)

After debugging for 6-hours - I am giving this up :| We have a nginx+php-fpm+mysql in LAN with almost 100 wordpress (created and used by different designers/developers all working on test wordpres ...
14
votes
1answer
7k views

How to disable http basic auth in nginx for a specific ip range?

I'm developing an application with facebook login. So far it's not public and is protected by http basic auth in nginx. Is it possible to disable http auth for facebook's ip range so that we can have ...
14
votes
5answers
7k 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, ...
14
votes
2answers
11k views

Nginx - root versus alias, for serving single files?

After many hours getting nginx to serve single files such as robots.txt (hint: clear your browser cache each time), I wound up with two different ways, one using the alias directive, and one using the ...
14
votes
1answer
19k views

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 document says From NginxHttpCoreModule try_files syntax: try_files path1 ...
14
votes
3answers
705 views

Does this prove a network bandwidth bottleneck?

I've incorrectly assumed that my internal AB testing means my server can handle 1k concurrency @3k hits per second. My theory at at the moment is that the network is the bottleneck. The server can't ...
13
votes
2answers
9k views

nginx + php-fpm - where are my $_GET params?

I have a strange problem here. I just moved from apache + mod_php to nginx + php-fpm. Everything went fine except this one problem. I have a site, let's say example.com. When I access it like ...
13
votes
2answers
6k views

Do HTTP reverse proxies typically enable HTTP Keep-Alive on the client side of the proxied connection and not on the server side?

HAProxy has the ability to enable HTTP keep-alive on the client side (client <-> HAProxy) but disable it on the server side (HAProxy <-> server). Some of our clients connect to our web service ...
13
votes
4answers
4k views

How well do nginx and memcached work together?

We have a Java EE-based web application running on a Glassfish app server cluster. The incoming traffic will mainly be RESTful requests for XML-based representations of our application resources, but ...
12
votes
2answers
481 views

Is there an elegant way to block a bunch of referrers at once?

In order to prevent referrer spam, my nginx.conf contains a section like this: if ($http_referer ~* spamdomain1\.com) { return 444; } if ($http_referer ~* spamdomain2\.com) { return 444; } if ...
12
votes
4answers
6k views

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 ...
12
votes
10answers
7k views

How to scale php5+MySQL above 200 requests/second?

I am tweaking my homepage for performance, currently it handles about 200 requests/second on 3.14.by which eats 6 SQL queries, and 20 req/second on 3.14.by/forum which is phpBB forum. Strangely ...
12
votes
4answers
7k views

Nginx Varnish Nginx Django?

I have a django app and I want to to setup Varnish on a server in front of it. In another serverfault thread somebody suggested putting Nginx in front of Varnish. Should I put Nginx in front of ...
12
votes
4answers
1k views

What does Nginx lack that Apache has?

Nginx is said to be much more resource-efficient and easier to configure than Apache. A friend told me that "it can't do some things that Apache can do, but I don't need those things anyway." Still, ...
12
votes
3answers
1k views

The downsides of using nginx as a primary web server?

I've seen millions of websites using nginx as a proxifying webserver working together with Apache. But I've seen very few servers running nginx only as their default webserver. What are the main ...
12
votes
3answers
2k views

Determining a realistic measure of requests per second for a web server

I'm setting up a nginx stack and optimizing the configuration before going live. Running ab to stress test the machine, I was disappointed to see things topping out at 150 requests per second with a ...
11
votes
3answers
10k views

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 ...
11
votes
4answers
15k 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; ...
11
votes
2answers
9k views

Nginx - Serve static content from a cookieless domain

I'm using the "page speed" extension for Firebug to try to optimise a website and I'm currently working on the following suggestion: "Serve static content from a cookieless domain". I have created a ...