Welcome! Log In Create A New Profile

Advanced

Re: default server with custom 404

Francis Daly
April 06, 2016 06:16PM
On Wed, Apr 06, 2016 at 02:26:25PM +0100, Robin Becker wrote:

Hi there,

> I see this question has been asked and answered many times, but I am
> unable to make it work.

It seems to work for me.

Are you certain that no caching in front of nginx is interfering with
your tests?

What do you see if you do something like

curl -v -H Host:anything http://your-server/should-give-404

?

> On a server with multiple virtual hosts I wish to make a catchall
> which responds to everything with a 404 that reveals no information.

What information does the default nginx internal 404 response reveal,
that your own file does not? See the "curl -v" response above for the
http headers.

> I am running nginx version: nginx/1.8.1 on ubuntu 14.04.
>
> My catchall looks like this
>
> server {
> listen 80 default_server;

This will be the default server over any others that have "listen *:80"
(in its various guises). If you have anything like "listen ip" anywhere,
then any connection to that IP will not use this server{}.

You most likely do not have "listen ip" anywhere. But just in case --
this is not necessarily a catch-*all*.

> 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.

That's not what I get.

If you still have the problem, perhaps the debug log will show more
about what is going on.

> Is there a way to customize my error page for this case?

What you have done should work. Depending on the rest of your config,
of course.

> Alternatively is there a way to override nginx's 404 page so it
> doesn't reveal the server.

Patch the code and recompile.

You probably don't want to do that.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

default server with custom 404

Robin Becker April 06, 2016 09:28AM

Re: default server with custom 404

Francis Daly April 06, 2016 06:16PM

Re: default server with custom 404

Robin Becker April 07, 2016 05:32AM

Re: default server with custom 404

Francis Daly April 07, 2016 08:18AM

Re: default server with custom 404

Robin Becker April 07, 2016 09:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 154
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready