Default error_page for multiple vhosts

Alexander Nestorov alexandernst at gmail.com
Fri Feb 22 08:32:33 UTC 2013


I'm trying to set a default error_page for my entire nginx server (as
in for all vhosts)

I'm using following settings:

http {
    error_page 404 /var/www/default/404.html;

    server {
        root /var/www/mydomain.com/;
    }
}

But I'm getting this error:
[error] 16842#0: *1 open()
"/var/www/mydomain.com/var/www/default/404.html" failed (2: No such
file or directory)

While I do understand the error, and I do understand why it's
happening, I can't understand why can't I tell NGINX to
user the default error_page as an absolute path instead of appending
it to the root of my vhost.

What I'm trying to achieve is being able to user
/var/www/default/404.html error_page from all my vhosts without
having to add it to all server{}. I think adding it for my 300 domains
is an overkill.

I asked in serverfault and I did got a semi-solution using includes,
but this solution still requires me to edit every
single server{}, which I really don't want to.

Is there any other way I could achieve what I'm trying?

Original serverfault question:
http://serverfault.com/questions/481140/nginx-default-error-page


Regards!


--
alexandernst



More information about the nginx mailing list