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

151
votes
5answers
106k 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 ...
102
votes
12answers
101k 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 ...
20
votes
1answer
27k 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 ...
10
votes
4answers
4k 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 ...
6
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 ...
10
votes
4answers
14k 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 ...
2
votes
2answers
303 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 ...
71
votes
7answers
47k 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 ...
16
votes
3answers
10k 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 ...
5
votes
2answers
4k 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
17k 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 ...
10
votes
1answer
13k 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: ...
9
votes
4answers
13k 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?
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: ...
3
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 ~* ...
4
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 ...
75
votes
5answers
20k 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. ...
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 ...
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 ...
14
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?
7
votes
3answers
24k 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
8k 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 ...
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
3answers
47k 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 ...
13
votes
5answers
6k 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, ...
7
votes
1answer
9k 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 ...
2
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. ...
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 ...
5
votes
1answer
9k 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 ...
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 ...
8
votes
3answers
8k 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
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 ...
2
votes
2answers
7k 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 ...
1
vote
1answer
2k 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 ...
11
votes
4answers
3k 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/ ...
3
votes
2answers
2k views

Nginx ignoring client's HTTP 1.0 request and respond by HTTP 1.1

I am testing using nginx/php5-fpm, with the code <?php header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); // also tested: header("Status: 404 Not Found"); echo $_SERVER["SERVER_PROTOCOL"]; ...
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 ...
2
votes
1answer
855 views

How should I structure my users/groups/permissions for a web server?

How should I setup permissions in the most secure way on my dedicated server which I'm running FTP + Nginx on? I want FTP to be able to read/write files and I want Nginx to be able to read/write the ...
2
votes
1answer
3k views

WebDav rename fails on an Apache mod_dav install behind NginX

I'm trying to solve a problem with renaming files over WebDav. Our stack consists of a single machine, serving content through Nginx, Varnish and Apache. When you try to rename a file, the operation ...
0
votes
4answers
342 views

How to make proxy on nginx?

How would I set my webservers to work in way described below? Http request: mypublic.com ---> handled normally by nginx as it is set up already (listen 80;) Http request: myprivate.com ---> handled ...
6
votes
4answers
3k views

nginx subdomain rewrite

Yet another nginx rewrite rule question How can I do a rewrite from http://www.*.domain.com to http://*.domain.com ? thanks in advance -- Deb EDIT: I'm sorry I didn't see the textile formatting ...
5
votes
4answers
536 views

How to replicate nginx data to two servers?

I'm trying to replicate the traffic that one specific nginx server receives to two servers. The goal is not to load-balance, but to replay the same input on all nginx servers. An example: Nginx ...
5
votes
2answers
6k views

Wildcard vhosts on Nginx

I've just installed Nginx on my server and am extremely happy with the results, however I still cannot figure out how to insert wildcard virtual hosts. This is the [directory] structure I'd like: -- ...
4
votes
3answers
5k views

How to use FastCGI globally and Basic Auth in sublocations in nginx?

I recently deployed my first nginx setup and everything works really nice, except the location parsing is driving me nuts. I have a simple php fastcgi setup like this: location ~ \.php { if (!-e ...
3
votes
3answers
2k views

Recompile NGINX with “--with-http_stub_status_module” configure line

I've installed NGINX with sudo apt-get install nginx and now I'd like to recompile it with the configure option --with-http_stub_status_module. How can I do this, and is there a way I can not loose ...
2
votes
2answers
785 views

How do I reserve bandwidth for rsync?

Currently nginx uses all my bandwidth. How do I leave some for rsync?