problem with setting Virtual Hosts

Francis Daly francis at
Wed Mar 23 21:07:52 MSK 2011

On Wed, Mar 23, 2011 at 01:16:14PM -0400, chatfeed wrote:

Hi there,

> I wrote as the following site.

Despite what it shows on that page, it is usually best...

>   server_name *; # Alternately: _
>   root /data/www/$host/;
>   error_page 404 errors/404.html;

...if the last argument to error_page starts with "/" or "@".

So make it "/errors/404.html" and you should see something more
useful. (Or just remove the line entirely, for a slightly different

> when i vist
> but the website redirect to the following site.
> http://a.domaincom/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/errors/404.html

You ask for; nginx presumably doesn't see the file
/data/www/ and so generates a http 404 error; your
error_page setting says "do an external redirect to errors/404.html",
which is returned to your browser.

It then asks for; nginx doesn't see
the file /data/www/ and generates a http
404 error which becomes an external redirect, so your browser asks for; and this continues until
your browser decides it has seen too many redirects.

So: delete or change the error_page line to prevent the loop; and add
content to the right directory to avoid the initial 404 error.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list