Nginx ("engine x") is a lightweight, high-performance HTTP server, reverse proxy, TCP stream proxy and mail proxy, released under a BSD-like license.

learn more… | top users | synonyms

14
votes
2answers
7k views

Suspicious symbols on nginx config

I have the following nginx config, e.g. server { listen 80; server_name example.com allow 127.0.0.0/8; When I restart, it warn me: Restarting nginx: nginx: [warn] server ...
14
votes
5answers
22k 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; ...
14
votes
2answers
1k 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 ...
14
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 ...
14
votes
3answers
826 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
4answers
33k 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 ...
13
votes
3answers
20k views

How to restart Nginx on Mac OS X?

I just installed Nginx on Mac OS X (thanks http://www.kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/), but how do I restart Nginx on Mac OS X? Thanks!
13
votes
3answers
9k views

nginx: bind() to 0.0.0.0:80 failed on Windows [closed]

I've been using nginx without any problem on windows for the last few months. Today when I tried to start it up, I got this error: nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was ...
13
votes
3answers
15k views

How to set a favicon.ico for a specific Virtual Host on Nginx?

I am using Nginx as my webserver for the first time. I didn't have any trouble to set it up and everything works great. The problem came when the designer asked me if he could send me "the icon in the ...
13
votes
2answers
9k 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
3answers
4k views

Alternatives to apache benchmark? [closed]

I'd like some tools for ubuntu that I can use to test my server, how much it can handle. Any suggestions? I've used apache benchmark before, but I'd like to try out something else. (As a side ...
13
votes
2answers
8k 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 ...
13
votes
2answers
12k views

User per virtual host in Nginx

Is it possible in nginx configure different user per virtual host? Something like server { user myprojectuser myprojectgroup; ... }
13
votes
1answer
12k views

nginx - client request body is buffered to a temporary file

I get the following error in my log files every time I try to upload a large file. a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001 Although the file uploads ...
13
votes
2answers
12k views

Tips for maximizing Nginx requests/sec?

I'm building an analytics package, and project requirements state that I need to support 1 billion hits per day. Yep, "billion". In other words, no less than 12,000 hits per second sustained, and ...
13
votes
3answers
2k views

How to write a DRY, modular nginx conf (reverse proxy) with named locations

I'm using nginx mostly as a reverse cachining proxy in front of several gunicon/mod_wsgi applications and of course to server static files. I find that quickly my nginx confs become impossible to ...
12
votes
3answers
15k 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: ...
12
votes
5answers
26k 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
12
votes
2answers
7k views

Nginx: force SSL on one path, non-SSL on others

How do I set up Nginx conf file to force SSL on only one of the paths in my site and non-SSL on all the rest? For example, I want all of the URLs under /user to be https but all the rest of the URLs ...
12
votes
3answers
7k 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 ...
12
votes
2answers
4k views

How can I configure nginx locations to share common configuration options?

How can i configure a shared config block for a set of locations? location / { proxy_pass http://127.0.0.1:9000/; proxy_redirect off; ...
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
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
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
15k views

Nginx: How do I forward a http request to another port?

What I want to do is, When someone visit http://localhost/route/abc the server response exactly the same as http://localhost:9000/abc Now I configure my Nginx like this: location /route { ...
12
votes
1answer
35k views

What is the name and location of the Nginx config file (htaccess equivalent)?

There are many tutorials on how to write Nginx rewrite rules to mimic Apache's .htaccess file but I can't confidently say I know what the name or location of this so-called Nginx config file actually ...
12
votes
5answers
17k 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 ...
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
6answers
5k views

What purpose does an empty gif (1x1 pix) file serve?

I've seen a few random pages mention using empty gif images to somehow increase performance. I've also found the nginx has a module for just this purpose. What I can't figure out, is exactly how ...
11
votes
4answers
19k 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 ...
11
votes
3answers
13k views

How to stop nginx on Mac OS X

I've installed and configured nginx server on my Mac from MacPorts sudo port install nginx Followed the recommendation from the port installation console and created the launchd startup item for ...
11
votes
4answers
14k views

How to output variable in nginx log for debugging

I am testing nginx and want to output variables to the log files. How can I do that and which log file will it go (access or error).
11
votes
2answers
10k 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 ...
11
votes
2answers
8k views

best way to debug nginx config file?

I have a bunch of rewrite rules that I have to port from apache to nginx. It's a rather painful process because I'm not able to see if my rewrite rules and "if" conditions are working as I want them ...
11
votes
3answers
20k views

How can I make nginx support @font-face formats and allow access-control-allow-origin?

I've added these rules to mime.types: application/x-font-ttf ttf; font/opentype otf; application/vnd.ms-fontobject eot; font/x-woff ...
11
votes
5answers
48k 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 ...
11
votes
2answers
517 views

Why is 14 characters the maximum length for the nginx server_name directive?

I have the following virtual host server { server_name abc.example.com; root /var/www/test/; index index.html; } When running nginx -s reload I get the following error: nginx: [emerg] ...
11
votes
1answer
6k views

nginx: [emerg] unknown directive “http”

When I try to make code like it: 1. http { 2. script 3. server { 4. ... 5. location ... 6. } 7. } I get error: nginx: [emerg] unknown directive "http" in ...
11
votes
3answers
15k 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 ...
11
votes
2answers
19k 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; ...
11
votes
2answers
6k 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 ...
11
votes
3answers
12k views

Make nginx to pass hostname of the upstream when reverseproxying

I run several docker containers with hostnames: web1.local web2.local web3.local Routing to these done based on hostname by nginx. I have a proxy in front of this setup (on different machine ...
11
votes
1answer
956 views

Passing SSL protocol info to backend via HTTP header

After Poodle vulnerability was revealed recently, our team decided to move on from SSLv3. But before complete removal, they want to warn the daily users that their browser use deprecated SSLv3. So, we ...
11
votes
4answers
5k 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/ ...
11
votes
4answers
10k views

Permission denied while reading upstream

We have deployed our rails application on on nginx and passenger.Intermittently pages of application get loaded partially.There is no error in application log.But nginx error log shows the following : ...
10
votes
2answers
1k views

Prefer IPv4 incoming connections over IPv6

We run a social/local service that benefits from geolocating the IP of users. The problem is that with IPv6, geolocation is quite a bit spottier than with IPv4. Is there a way to prefer incoming ...
10
votes
6answers
1k views

How to upgrade software installed from source?

I install NGinx from source since the packages from the ubuntu repository are quite old. I was wondering what is the best method to upgrade these types of installations? My current workflow involves. ...
10
votes
3answers
3k views

When should I switch to NGinx?

I have a server with several domains and applications running, all through Apache. All is well at the moment but I have plans to develop some very performance-intensive web application (using C++ with ...
10
votes
4answers
20k 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 ...
10
votes
1answer
9k 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 ...