default server with custom 404
Robin Becker
robin at reportlab.com
Wed Apr 6 13:26:25 UTC 2016
I see this question has been asked and answered many times, but I am unable to
make it work.
On a server with multiple virtual hosts I wish to make a catchall which responds
to everything with a 404 that reveals no information.
I am running nginx version: nginx/1.8.1 on ubuntu 14.04.
My catchall looks like this
server {
listen 80 default_server;
listen 443 ssl default_server;
allow all;
charset utf-8;
error_page 404 /404.html;
root /mypath/html/;
location = /404.html {
root /mypath/html/;
}
location / {
return 404;
}
}
if I make a fake /etc/hosts dns say dongo.bilbo.com and point at my server then
http://dongo.bilbo.com/404.html shows me the correct 404 page with no Nginx
info, however, any other path eg http://dongo.bilbo.com always shows me the
standard Nginx 404 page.
Is there a way to customize my error page for this case?
I would add that the following works well for my real sites
> charset utf-8;
> error_page 404 /404.html;
> location /404.html {
> root /mypath/html;
> }
and there I do see the 404.html from /mypath/html when I visit missing pages.
Alternatively is there a way to override nginx's 404 page so it doesn't reveal
the server.
--
Robin Becker
More information about the nginx
mailing list