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

8
votes
5answers
15k views

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
8
votes
7answers
5k views

Varnish -> Nginx -> Apache a good idea?

I'm thinking about the architecture for a new Webserver. Would having Varnish as a cache in front of Nginx as a reverse-proxy and serving static files in front of apache for all heavy lifting be a ...
8
votes
1answer
5k views

The strange case of Mr. Time To First Byte

I've got a webserver on a Linode 1024 VPS based on Ubuntu 11.10 Nginx 1.0.5 PHP 5.3.6 (with PHP-FPM, APC) Varnish 3.0.2 And a couple of blogs there based on WordPress 3.3.1. One of them is a ...
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
15k views

Cross Origin Resource Sharing (CORS) with nginx / chrome

I have a website with the following segmentation: api.example.com developers.example.com example.com I would like to allow both example.com and developers.example.com to make AJAX requests to ...
8
votes
2answers
4k views

“Hide” .html file extensions using nginx rewrites

I'm serving up a static site via nginx, and my goal is to replace URL's that look like: http://foo.com/bar.html with http://foo.com/bar The key being no trailing slash. I am currently doing ...
8
votes
3answers
15k views

nginx automatic failover load balancing

I'm using nginx and NginxHttpUpstreamModule for loadbalancing. My config is very simple: upstream lb { server 127.0.0.1:8081; server 127.0.0.1:8082; } server { listen 89; ...
8
votes
3answers
425 views

Make Nginx server respond slowly

So I have a spammer on my site. I could block his IP using 'deny', but then he'll just change his IP and I'll have to keep playing cat and mouse with him. Instead, I am curious if there is a way to ...
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 ...
8
votes
1answer
8k views

Configure Nginx as reverse proxy with upstream SSL

I try to configure an Nginx server as a reverse proxy so the https requests it receives from clients are forwarded to the upstream server via https as well. Here's the configuration that I use: http ...
8
votes
2answers
3k views

Setting Nginx to catch all unhandled vhosts

If I already have a bunch of virtualhosts, how can I create a virtual host to handle requests that don't match any of the virtualhosts? (i.e. access by IP, another domain linking to IP, .etc .etc)
8
votes
1answer
1k views

What causes a 400 Bad Request error for null (“”) and why would our nginx logs have so many?

Daily logs from Logwatch regularly report 400 Bad Request, null: 1744 Time(s) from our nginx logs. The log entries look like: 123.123.123.123 - - [25/Jan/2011:14:44:19 -0500] "-" 400 173 "-" "-" ...
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 ...
8
votes
1answer
867 views

Nginx learning resources

I would like to learn Nginx (I'm trying to setup a nginx+thin(s) rails solution on linux). I know russian but the original nginx documentation is a bit hard to understand for me. Please advice on good ...
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 ...
8
votes
1answer
2k views

How do I configure nginx to accept gzip requests?

I know that you can use nginx HttpGzipModule to gzip responses. Can you als use it to enable nginx to handle gzip-compressed requests, i.e. ones with the request header: Content-Encoding: gzip ? ...
7
votes
3answers
15k views

Nginx enable site command

We all know how to enable a website using apache on linux. I'm pretty sure that we all agree on using the a2ensite command. Unfortunately there is no default equivalent command comes with Nginx, but ...
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
17k views

How can I make sure that Nginx serves plaintext files as a download, instead of inline?

I have Rails application (Redmine) which works with Nginx. If I am clicking on any attachment my browser (firefox, ie, chrome) ask me to download file. But if I am clicking on txt-type attachment my ...
7
votes
1answer
11k views

Nginx multiple location issues

I'm currently trying to break apart 3 applications from one repository into 3, but keeping the url structure, so basically different locations under the same domain have to be delivered by different ...
7
votes
3answers
7k views

nginx: dump HTTP requests for debugging

Ubuntu 10.04.2 nginx 0.7.65 I see some weird HTTP requests coming to my nginx server. To better understand what is going on, I want to dump whole HTTP request data for such queries. (I.e. dump all ...
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 ...
7
votes
2answers
2k views

Nginx : thousands of server_name

how can I configure Nginx restrict to thousands of different server_name without creating thousands of external config files or writing a very long server_name line ? Indeed, I would like Nginx be a ...
7
votes
2answers
1k views

Nginx add_header for a 50* page

I'm currently trying to get nginx to add a header to the response when it is sending some kind of 50* error. I already have an add_header directive on the http block, and that gets respected for all ...
7
votes
6answers
2k views

How can I keep Apache from falling over?

I have a pair of servers hosting a single Magento ecommerce site with moderate traffic (60k page views per day reported from google analytics, I think about 80k reported on the server itself). The ...
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 ...
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 ...
7
votes
1answer
2k views

mod_rpaf problems with Nginx front, Apache back-end after Ubuntu upgrade

I'm running an Nginx front-end for static files, and proxying to an Apache backend for PHP and Passenger, using Apache's mod_rpaf to set the correct remote IP address on the backend. Everything worked ...
7
votes
3answers
8k views

Why cache static files with Varnish, why not pass

I have a system runnning nginx / php-fpm / varnish / wordpress and amazon s3. Now I have looked at a lot of configuration files while setting up the system, and in all of them I found something like ...
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 ...
7
votes
3answers
3k views

nginx passing back custom header

I have the following example location / { proxy_read_timeout 2000; proxy_next_upstream error; proxy_set_header X-Real-IP ...
7
votes
2answers
1k views

Is it possible to use Shibboleth 2 with Nginx + Passenger?

Do you know if it is possible to use Nginx with Shibboleth?
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: ...
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
2answers
5k views

When nginx is configured as reverse proxy, can it rewrite the host header to the downstream server like Apache's ProxyPreserveHost?

I can't seem to find the equivalent of Apache's ProxyPreserveHost http://httpd.apache.org/docs/2.0/mod/mod%5Fproxy.html#proxypreservehost option in nginx. This is required to reverse proxy to virtual ...
7
votes
2answers
3k views

uploading files greater than 1MB = connection resets

I'm using nginx on the frontend as "proxy cache" and apache on the backend, i've set my PHP settings to the following: error_log = /var/www/site1/php_error.log error_reporting = 22527 file_uploads = ...
7
votes
1answer
2k views

Why isn't the Nginx Gzip Precompression module working?

I'm currently trying to set up Nginx to serve all of my static files. Since they will not be changed very frequently at all I want to us the gzip_static module to allow me to pre-gzip copies of my ...
7
votes
5answers
4k views

Which reverse-proxies support HTTP/1.1 ETag and If-None-Match headers?

I'm developing a caching system for an ecommerce platform that will use a reverse proxy for caching. I plan to handle invalidation by using proper HTTP/1.1 headers. That is, I will set an ETag on ...
7
votes
3answers
8k views

How do I configure Nginx proxy_pass Node.js HTTP server via UNIX socket?

I am trying to configure a Nginx server to connect to a Node.js HTTP server via a UNIX domain socket. The Nginx configuration file: server { listen 80; location / { proxy_pass ...
7
votes
2answers
6k views

SSH over HTTPS with proxytunnel and nginx

I'm trying to setup an ssh over https connection using nginx. I haven't found any working examples, so any help would be appreciated! ~$ cat .ssh/config Host example.net Hostname example.net ...
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
663 views

Understanding the nginx proxy_cache_path directive

Suppose I have this nginx config file proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=myCache:8m max_size=100m inactive=1h; What does the keys_zone=myCache:8m mean? There's not much said to ...
7
votes
2answers
3k views

What is the different usages for sites-available vs the conf.d directory for nginx

I have some experience using linux but none using nginx. I have been tasked with researching load-balancing options for an application server. I have used apt-get to install nginx and all seems ...
7
votes
2answers
573 views

How to set only specific nginx server block into maintenance mode programmatically

I am looking for a solution to automate one of our application's deployment process. In the beginning of deployment, I would like to programmatically set the specified server into maintenance mode and ...
7
votes
1answer
1k views

Can I alias all directory requests to a single file in nginx?

I'm trying to figure out how to take all requests made to a particular directory and return a json string without a redirect, in nginx. Example: curl -i http://example.com/api/call1/ Expected ...
7
votes
1answer
1k views

NGINX on OSX - Performing terribly slow

I I've been trying to get NGINX up and running on my OSX 10.7 Lion computer. I have it running however simple html pages every few are taking a long time to load; for example: <html> ...
7
votes
2answers
697 views

nginx proxy retry while backend is restarting

Nginx returns 502 while the backend is restarting. How can I make nginx proxy retry N times with M seconds delay? Is there a plugin or something else?
7
votes
3answers
1k views

nginx: How to prevent an exactly named SSL server block from acting as the catchall for all SSL

I have a web server with many virtual servers. Only 1 of which is SSL. The problem is, because there is no catchall server block listening for SSL, any https request to the other sites is served by ...
7
votes
3answers
709 views

What is the best tool to aggregate traffic stats from multiple nginx servers?

The setup: 2 or more nginx machines each machine has the same virtual hosts traffic is load balanced via DNS to each machine I need to figure out what are the best tools to use to get some traffic ...
6
votes
4answers
1k views

Serving html from linux ramdisk

I have seen a somewhat dated tutorial that suggest serving html files with a ramdisk like this: mkfs -q /dev/ram1 102400 I also find another source that use something like this: mount -t tmpfs -o ...