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

172
votes
5answers
129k 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 ...
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 ...
105
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 ...
78
votes
7answers
59k 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 ...
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 ...
10
votes
4answers
16k views

Nginx + php5-fpm = “File not found”

I've hit a wall whilst setting up a site using nginx / fpm. The page displays "File not found", and this appears in the nginx error.log: FastCGI sent in stderr: "Primary script unknown" while reading ...
7
votes
3answers
2k views

NGINX as http proxy server (not reverse proxy) [closed]

Is it possible to use nginx as ordinal http/https proxy? (not reverse http proxy) UPDATE: Yes, i know about squid/oops/tinyproxy/etc. Please do not answer if you dont know answer to question (or just ...
4
votes
1answer
2k views

What is Apache's equivalent of Nginx's try_files?

In Nginx there is try_files, a config directive that "checks for the existence of files in order, and returns the first file that is found". I find it very neat to do this location ~* ...
2
votes
1answer
247 views

Nginx rewite rules 403 error

I am having trouble with converting .htaccess files to nginx. I have 3 .htaccess files. The first .htaccess file is located in the document root and is as follows: Options +FollowSymLinks ...
2
votes
2answers
330 views

nginx location pathing issue

I've got a pretty much default sites-enabled set up in my nginx on debian squeeze and i'm now trying to get it to serve up my munin graphs on myhost/munin/ Heres the location i've added to the config ...
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. ...
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 ...
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 ...
6
votes
2answers
5k views

nginx+django serving static files

I have followed instruction for setting up django with nginx from the django wiki (https://code.djangoproject.com/wiki/DjangoAndNginx) and have nginx setup as follows (a few name changes to fit my ...
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 ...
15
votes
1answer
988 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: ...
10
votes
1answer
17k views

Nginx reverse proxy + URL rewrite

Nginx is running on port 80, and I'm using it to reverse proxy URLs with path /foo to port 3200 this way: location /foo { proxy_pass http://localhost:3200; ...
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: ...
10
votes
4answers
15k views

nginx + PHP-FPM = “permission denied” error 13 in nginx log; configuration mistake?

I've got nginx 0.7x + PHP-FPM running under PHP 5.2.10 on one RHEL5 server, but trying to duplicate that setup under the bundled-in PHP-FPM in PHP 5.3.3 on a second server, I'm having some trouble ...
5
votes
1answer
2k views

Nginx protect directory with password, except for specific ip's

In my Nginx setup I would like to password protect some website, except when I access it from my ip at home. How do I set this up? Also, except for getting access to my home pc, is this safe?
3
votes
2answers
3k views

understanding max file descriptors for linux and nginx, and best value for worker_rlimit_nofile

I got the seemingly-common "too many file descriptors" error on nginx. After much searching, the solution is clearly to increase the number of file descriptors available to nginx. But there isn't ...
5
votes
2answers
4k views

Nginx (for static files) and Apache (for dynamic content)?

So, my entire application runs on apache just fine. However, I want to test how much the requests per second increases if I put all static files through nginx instead. I found this thread: ...
5
votes
1answer
4k views

Can nginx listen on port 80, but send upstream to backend using SSL on 443?

For PCI compliance, my application is forced to use a secure/encrypted connection between the reverse proxy server and backend app server, whereas the connection coming into the reverse proxy is on ...
3
votes
2answers
3k views

Nginx: Forward all Subdomains

My code doesn't work with second level tld's like domain.co.uk Here is my conf: # add www. if ($host ~ ^(?!www)) { rewrite ^/(.*)$ http://www.$host/$1 permanent; } # remove subdomain ...
1
vote
1answer
674 views

Strange request in access.log, how to block?

I am using nginx on my own server, and I noticed a few days ago some strange request in my access.log : 77.50.217.37 - - [19/Aug/2011:17:50:50 +0200] "GET http://images.google.com/ HTTP/1.1" 200 151 ...
2
votes
1answer
118 views

How can I get around using alias in nginx?

Due to a long-standing bug in nginx I was advised to switch my alias directive with a root directive. Unfortunately this now breaks my static files, which are located in a different directory to my ...
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 ...
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 ...
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 ...
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 ...
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?
10
votes
3answers
10k views

How to rewrite the domain part of Set-Cookie in a nginx reverse proxy?

I have a simple nginx reverse proxy: server { server_name external.domain.com; location / { proxy_pass http://backend.int/; } } The problem is that Set-Cookie response headers contain ...
7
votes
3answers
25k views

What is wrong in my php-fpm configuration?

I have a 64-bit server but only 256MB of RAM. So, I moved to nginx server with fast-cgi to connect to PHP. I have PHP 5.3.6 running. The issue is that after every two or three days when I try to ...
7
votes
3answers
12k views

nginx rewrite for an url with parameters

I have an URL of this type: http://www.example.com/?param1=val1&param2=&param3=val3&param4=val4&param5=val5 And I want to redirect it to this one: ...
8
votes
1answer
11k views

how do I get nginx to forward HTTP POST requests via rewrite?

My iOS app is currently accessing domain A via http POST but I would like to forward all requests to domain B. If I use the usual "rewrite ^/(.*)$ http://mydomain/$1 permanent;" the POST data ...
3
votes
3answers
5k views

cakephp & nginx config/rewrite rules

Hi somebody please help me out, I've asked this at stackoverflow as well but not got much of a response and was debating whether it was programming or server related. I’m trying to setup a cakephp ...
15
votes
4answers
56k 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 ...
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, ...
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 ...
3
votes
6answers
6k views

Apache, nginx, or lighttpd? [closed]

I am going to be live blogging from an event and expect huge spikes in traffic. I am currently using apache with modphp and it died last year under heavy traffic and I don't want it to happen again. ...
6
votes
1answer
10k views

Apache MPMs - Worker vs Prefork

I'm trying to figure out what which is the best Apache MPM I can install on my VPS. I saw some benchmarks and MPM Worker seems to perform better than the Prefork one but for some reason everyone seems ...
4
votes
2answers
2k views

How to setup Nginx with Varnish

I'd like to see how to configure Nginx and Varnish. I'm running several PHP sites and Rack-Sinatra sites as virtual hosts across two IP's. I'd like to prevent Nginx from having to serve static ...
7
votes
4answers
3k views

Experience in migrating from Apache to nginx?

I'd like to get some feedback about a migration From Apache to nginx. My goal is to reduce the memory footprint of the web server. Currently, I use the following modules.features on Apache: multiple ...
3
votes
2answers
2k views

Requests per second slower when using nginx for load balancing

I've set up nginx as a load balancer that reverse proxies requests to 2 Apache servers. I've benchmarked the setup with ab and am getting approx 35 requests per second with requests distributed ...
3
votes
2answers
1k views

Apache-style multiviews with Nginx

I'm interested in switching from Apache/mod_php to Nginx for some non-CMS sites I'm running. The sites in question are either completely static HTML files or simple PHP, but the one thing they have in ...
2
votes
2answers
5k views

Nginx set_real_ip_from AWS ELB load balancer address

I have a set of Nginx servers behind an Amazon ELB load balancer. I am using set_real_ip (from the HttpRealIpModule) so that I can access the originating client IP address on these servers (for ...
2
votes
1answer
3k views

Nginx appends the path given in the URI

I'm trying to configure phpMyAdmin so I've set the flowing location in Nginx however it apends the "pma" to the root directory: 2012/08/14 13:59:49 [error] 10151#0: *2 ...
2
votes
2answers
8k views

Alias using Nginx causing phpMyAdmin login endless loop

Recently I've been trying to set up a web server using Nginx (I normally use Apache). However I've ran into a problem trying to set phpMyAdmin up on an alias. The alias correctly takes you too the ...
11
votes
4answers
4k views

SSL Handshake negotiation on Nginx terribly slow

I am using Nginx as a proxy to 4 apache instances. My problem is that SSL negotiation takes a lot of time (600 ms). See this as an example: http://www.webpagetest.org/result/101020_8JXS/1/details/ ...
9
votes
4answers
27k views

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 ...