Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I figured this out, see first answer below

I have a fairly simple test config for an NGINX server that proxies to a Tornado server:

    server {
        listen       80;
        server_name  _;

        location = / {
            proxy_set_header   X-Real-IP        $remote_addr;

        error_page  404              /404.html;
        location = /404.html {
            root   /usr/share/nginx/html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;

Simple enough, when I access it all works fine, but if I access it triggers a 404, and in the error log it says

2011/06/06 18:39:24 [error] 23948#0: *100 open() "/usr/share/nginx/html/somefile.html" failed (2: No such file or directory), client:, server: _, request: "GET /somefile.html.html HTTP/1.1", host: ""

Which looks as though NGINX isn't passing /somefile.html on to the proxy. Going directly to works fine, and if I create /usr/share/nginx/html/somefile.html NGINX shows the contents of that file instead of proxying to the correct server.

I can't remember this ever happening before on any of my NGINX servers so I'm completely confused

If it's of any use, it's NGINX 0.7.67 on RHEL 5.5

share|improve this question
Just FYI, the tutorial you've been following is wrong. server_name _ does not create a "catch all" server block. The reason it probably seems like that is Nginx will use the first server block specified if none match. So if you ever add another server block before that one you will be confused. – Martin Fjordvald Jun 6 '11 at 22:55
@Martin I'm not following a tutorial, I built the config from memory (Hence why it didn't work haha). There is only one server{} block in the config anyway, and there will never be any more. – Smudge Jun 6 '11 at 23:21
Then the tutorial you read back then is wrong. :) I still suggest you remove the server_name and instead use the default_server flag on listen, in my experience "never" really means "no plans to" and "no plans to" turns into "plans got changed". – Martin Fjordvald Jun 7 '11 at 12:15
@Martin I can absolutely assure you 100% that this server will never have more than one VHost on =) It's just an EC2 dev box, my NGINX configs for live servers actually work haha (Also we don't use virtual hosts, we just get a unique IP for each site, our server came with 38 IPs so instead of using server_name we do listen; with a different IP for each host. Interestingly when we got rid of virtual hosts the load on our server dropped, only slightly but it was still noticeable so I concluded vhosts are an unnecessary overhead when we've got a big-ish netblock). – Smudge Jun 7 '11 at 12:56
up vote 0 down vote accepted

Oh #fail

For the purposes of educating anyone else as stupid as me, using

location = / {

will match only / but using

location / {

will match the directory / (Including all sub-folders/files etc.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.