Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
omega8cc CreditAttribution: omega8cc commentedThe 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 dummyserver_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.
Comment #2
anarcat CreditAttribution: anarcat commentedSo 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:
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?
Comment #3
omega8cc CreditAttribution: omega8cc commentedIn Nginx we could simply use a line like this:
return 404;
Comment #4
anarcat CreditAttribution: anarcat commentedthat would be much better, thanks! :)
Comment #5
anarcat CreditAttribution: anarcat commentedRelated: #1986314: distinguish between missing files (404) and missing hosts (406?).
Comment #6
omega8cc CreditAttribution: omega8cc commentedFixed 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.
Comment #7
anarcat CreditAttribution: anarcat commentedalright, thanks. i copied your comment in the right issue.