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

9
votes
3answers
8k views

Enabling nginx Chunked Transfer Encoding

It looks like nginx 0.8.35 may support chunked transfer encoding: Changes with nginx 0.8.35 01 Apr 2010 *) Change: now the charset filter runs before the ...
5
votes
3answers
1k views

Can you rely on Nginx as your only webserver for php/mysql

Can you rely on Nginx to be your only webserver. I know in terms of performance it works well, but how does it do in terms of security. I know Apache is stable and has ModSecurity. This is not the ...
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 ...
11
votes
2answers
6k views

nginx url rewriting: difference between break and last

I don't understand the difference between break and last (flags of rewrite). The documentation is rather abstruse. I've tried to switch between the two in some of my configs, but I couldn't spot any ...
4
votes
2answers
5k views

How to Create Jailed Users?

My servers run CentOS: Nginx + PHP-FPM (PHP via Fast-CGI). Every site is on its own VirtualHost. Currently both Nginx and PHP-FPM run under root. I know this is bad practice, and there is no reason ...
10
votes
2answers
9k views

User per virtual host in Nginx

Is it possible in nginx configure different user per virtual host? Something like server { user myprojectuser myprojectgroup; ... }
9
votes
3answers
10k views

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: ...
7
votes
6answers
2k views

why no examples of horizontally scalable software load balancers balancing ssl?

I have a bunch of questions with respect to ssl, local sessions, and load balancing which seem to be interconnected, so I apologize in advance for the length of this question. I have a website which ...
14
votes
3answers
706 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 ...
9
votes
5answers
8k views

How to get nginx to redirect from www to non-www domain?

Let's say I want to redirect from www.example.com to example.com and I want to do this using nginx. I looked around and did not see any good documentation on this so I figured I would ask and answer ...
8
votes
1answer
2k views

Poor load balancer performance on rackspace and centos

I am load testing different options for load balancing, and am getting poor results from Nginx, haproxy, and varnish. I have one 4GB load balancer at Rackspace, hitting 4x1GB app servers. I'm ...
6
votes
4answers
2k views

Nginx + Apache trailing slash redirect

I have a Nginx server running on 80 port working as a proxy to Apache 2.2 which is listening to 127.0.0.1:8080 When I access http://hostname/subfolder/ it works great. When I access ...
4
votes
2answers
2k views

How To limit Nginx Auth_Basic re-tries?

I have protected a web folder with Nginx's Auth_Basic module. The problem is, we can try several passwords until it works (brute force attacks). Is there a way to limit the number of failed re-tries?
3
votes
1answer
2k views

uwsgi_params not in nginx

Firstly I setup nginx and uwsgi via apt-get. And,I add the line to nginx conf file(/etc/nginx/conf.d/default.conf) like below line; server { listen 80; server_name <replace with your ...
3
votes
2answers
1k views

Cheap way to detect client round trip times for http

I am trying to figure out a way to detect round trip times for each IP that connects to port 80 on my server. What is a good way to do this? There are far to many connections, and pinging each ip is ...
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 ...
11
votes
5answers
14k views

Why are my PHP files downloading instead of processing with Nginx

I have seen the same problem, and many resolutions for it pointing to adding the type handler, but that was for Apache. I am using Arch Linux, Nginx, PHP and PHP-FMP and I cannot figure out why php ...
6
votes
2answers
2k views

nginx case insensitive rewrite

I am trying to make my nginx redirects as clean as possible. I understand ~* is for case insensitive but I can only get it to work in example 2. Example 1 rewrite ^/foobar ...
6
votes
2answers
3k views

How to rate-limit in nginx, but including/excluding certain IP addresses?

I'm able to use limit_req to rate-limit all requests to my server. However I'd like to remove the rate restriction for certain IP addresses (i.e. whitelist) and use a different rate restriction for ...
6
votes
6answers
3k views

PHP-CGI Started Serving Blank Pages

My PHP-CGI started serving blank pages for no apparent reason until I restarted the process. I want to know why. Unfortunately the "production" configuration file of PHP has no error_log by default. ...
5
votes
1answer
436 views

How do I verify site ownership on Google Webmaster Tools through nginx.conf?

Since a couple of years ago, Google Webmaster Tools site ownership verification process started to require that verification files have certain content, instead of simply being there and returning 200 ...
5
votes
1answer
1k views

add_header directives in location overwriting add_header directives in server

Using nginx 1.2.1 I am able to add multiple headers using add_header as follows: server { listen 80; server_name localhost; root /var/www; add_header Name1 Value1; <=== ...
5
votes
2answers
5k views

“ImportError: No module named flask” - Trouble with nginx + uWSGI + Flask in a virtualenv setup

I got nginx + uWSGI running on localhost inside a virtualenv with a simple hello world program, but I get this error when I replace the hello world with a simple Flask app: File ...
5
votes
4answers
5k views

What are the Differences between HAProxy and Ngnix in reverse proxy mode?

What are the differences between HAProxy and Nginx when it comes to their abilities as a reverse proxy?
5
votes
1answer
5k views

Blank Page: wordpress on nginx+php-fpm

Good day. While this post discusses a similar setup to mine serving blank pages occasionally after having made a successful installation, I am unable to serve anything but blank pages. There are no ...
5
votes
1answer
5k views

Nginx + PHP-FPM = “Random” 502 Bad Gateway

I am running Nginx and proxying php requests via FastCGI to PHP-FPM for processing. I will randomly receive 502 Bad Gateway error pages - I can reproduce this issue by clicking around my PHP websites ...
4
votes
3answers
2k views

Dynamic nginx domain root path based on hostname?

I am trying to setup my development nginx/PHP server with a basic master/catch-all vhost config so that I can created unlimited ___.framework.loc domains as needed. server { listen 80; ...
4
votes
4answers
5k views

Howto Nginx + git-http-backend + fcgiwrap (Debian Squeeze)

I am trying to setup git-http-backend with Nginx but after 24 hours wasting time and reading everything I could I think this config should work but doesn't. server { listen 80; server_name ...
4
votes
3answers
7k views

Can Nginx handle php (or similar fcgi) requests inside of an alias?

I am converting a legacy Apache server to Nginx and do not have the luxury of changing URL's or rearranging the filesystem. Is it possible to use nested location{} blocks in the Nginx configuration ...
2
votes
1answer
1k views

nginx reverse proxy slows down my throughput by half

I'm currently using nginx to proxy back to gunicorn with 8 workers. I'm using an amazon extra large instance with 4 virtual cores. When I connect to gunicorn directly I get about 10K requests/sec. ...
2
votes
2answers
1k views

Building an SSL server farm

I'm interested in building the the architecture in the article referenced below. I currently have a modestly-priced layer-4 load balancer and my application servers are the SSL endpoints. I want to ...
2
votes
1answer
4k views

How can I observe what nginx is doing? (to solve: “1024 worker_connections are not enough”)

I have a very low traffic site running on nginx, with 4 workers, 1024 connections each. Every several hours I start seeing in the error log "1024 worker_connections are not enough", and my site slows ...
2
votes
3answers
2k views

NginX & PHP-FPM, random 502

2010/09/19 14:52:07 [error] 1419#0: *10220 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: [...], server: [...], request: "POST /[...] HTTP/1.1", ...
1
vote
3answers
3k views

Is it possible to log the response data in nginx access log?

I am trying to print the response data for development/debugging purposes. I couldn't find a similar question or any info on this. If you do, please add a comment.
0
votes
1answer
216 views

nginx - limiting bandwidth usage per server block

In Apache we have some great solutions for limiting the bandwidth usage per vhost, like mod_bandwidth. However, since I started using nginx, I couldn't find a way of limiting and monitoring the ...
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 ...
9
votes
3answers
31k views

nginx fastcgi “Primary script unknown” when configuring userdir

I hate configuring nginx. It's so complicated. How do I get PHP to work in my user dirs? Here's the relevant part of my nginx.conf: location ~ ^/~(.+?)(/.*)?$ { autoindex on; ...
8
votes
4answers
3k views

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 ...
8
votes
2answers
14k views

Understanding this error: apr_socket_recv: Connection reset by peer (104)

So, if I do some benchmarking with apache benchmark (ab), and I use large numbers of requests. Then sometimes in the middle of a test I get this error. I don't even know what it means. So how can I ...
7
votes
1answer
2k views

NGINX convert HEAD to GET requests

Due to some terrible design decisions, we have an application unable to respond to HTTP HEAD requests (Returns 'Method Not Allowed'). Modifying the software to return HEAD requests correctly would be ...
7
votes
1answer
8k views

How do I set a default host for nginx?

I'm trying to figure out how to set a default host for my nginx installation. I found this article in the nginx Wiki: http://wiki.nginx.org/NginxVirtualHostExample#A_Default_Catchall_Virtual_Host ...
7
votes
1answer
2k views

Use Nginx to server different pages depending on IP address/subnet

For reasons to hideous to go into... I'm using Nginx as a webserver and would like it to serve one page for internal users (say on 10.0.0.0/16) and another page to external users on any other IP ...
6
votes
1answer
4k views

Working Nginx fastcgi_cache php-fpm cache and static file caching configuration?

Nginx wiki is very vague with explanation as to how to properly setup nginx with php-fpm with fastcgi_caching for sites which have cookies i.e. wordpress, drupal, vbulletin etc. I downloaded a ...
5
votes
2answers
8k views

Nginx - How to redirect users with certain IP to special page

I run quite a big image gallery and there are 5 visitors that create an enormous amount of traffic by downloading the whole site every day using webcopiers. Those visitors have static IPs as it seems. ...
4
votes
1answer
6k views

How to use nginx as reverse proxy with multiple IPs and SSL?

I would like to setup nginx reverse proxy with multiple domains and an IP for each of them to use different SSL Certs. I run Ubuntu as OS which is installed on a KVM/Qemu VM. As I understand nginx, ...
3
votes
1answer
3k views

Nginx - basic http authentication on PHP-script

I added a PHP-Script that serves as "cgi-bin", Configuration: location ~^/cgi-bin/.*\.(cgi|pl|py|rb) { gzip off; fastcgi_pass 127.0.0.1:9000; fastcgi_index cgi-bin.php; ...
2
votes
3answers
1k views

Use HAProxy or Nginx to Load Balance between VPS

I want to load balance + failover backup multiple vps webservers hosted on different providers. I heard that for HAProxy you need multiple server under the same subnet, plus a shared (virtual) ip ...
2
votes
1answer
6k views

How to configure php-fpm to log logs to log files configured in nginx virtualhosts

I have Fedora 16 with nginx and php-fpm. Everything is working very good. All logs with php notice,warnig error etc. are in /var/log/php-fpm/www-error.log. Is there a way to configure php-fpm to write ...
2
votes
1answer
581 views

Is it possible to configure Nginx to allow for new domains to be added without me having to add a VirtualHost for each?

I have a SaaS application wherein users can enter their domain names. The application uses the hostname of incoming requests to determine the account based on the domain they entered for their ...
2
votes
5answers
13k views

How do I make Nginx redirect all requests for files which do not exist to a single php file?

I have the following nginx vhost config: server { listen 80 default_server; access_log /path/to/site/dir/logs/access.log; error_log /path/to/site/dir/logs/error.log; root ...