The default nginx server included in the nginx.conf configuration is as follows:

#######################################################
###  nginx default server
#######################################################

server {
  limit_conn   gulag 32; # like mod_evasive - this allows max 32 simultaneous connections from one IP address
  listen       127.0.0.1:80;
  server_name  _;
  location / {
     root   /var/www/nginx-default;
     index  index.html index.htm;
  }
}

This yields a 404, as nginx-default doesn't exist. If the intention was to yield a 404 (like it's done in Apache), there are surely better ways. This overrides the builtin default server that Debian ships which provides a nicer interface.

Comments

omega8cc’s picture

The intention was to provide the default catch-all server with server-wide static 404 page, hence the server_name _; wildcard, while Debian (at least Squeeze) comes with rather useless in this context default server which doesn't have a wildcard, just a dummy server_name localhost;

We should probably document this better. Or maybe use the current default catch-all server only with standard/legacy config (just better documented), but remove from 'bare bones' option, so Debian own default server will be left for the sysadmin to configure/tune. Not sure, also because the default may change between Debian versions or even Nginx versions shipped with Debian etc.

anarcat’s picture

Title: default nginx server is a 404 » default nginx server is a 404, but doesn't make that clear in the config

So I am still trying to sort through how this all works, please bear with me. What happened here is that my hostmaster site was actually returning 404 here, so I kind of freaked out. But that's a different issue, see #1975188: nginx default server overrides configured vhosts for that.

What I feel is that this vhost should be made more obvious. Apache uses this configuration snippet:

  Redirect 404 /

That way, someone trying to read that config file understands this is an explicit 404 we are giving out there. In fact, it should probably be made clearer as a comment in that Apache config file.

Is there an equivalent to the above Apache command in Nginx?

omega8cc’s picture

In Nginx we could simply use a line like this:

return 404;

anarcat’s picture

that would be much better, thanks! :)

anarcat’s picture

omega8cc’s picture

Status: Active » Fixed

Fixed in http://drupalcode.org/project/provision.git/commit/f1f6d60

As for the 406 - my opinion is that it will add confusion, because it doesn't say clearly what we want. 404 is at least easy to understand and, in fact, also correct.

anarcat’s picture

alright, thanks. i copied your comment in the right issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit f1f6d60 on dev-drupal-8, 6.x-2.x, dev-ssl-ip-allocation-refactor, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x by omega8cc:
    Issue #1975178 by anarcat - default nginx server is a 404, but doesn't...