Is it possible to define a common location for all servers? From nginx location documentation I've seen that location depends on server. I would like to do something like this:
...
http {
error_page 404 /error/404.html;
error_page 500 501 502 503 504 /error/50x.html;
location ^~ /error/ {
internal;
root /var/www/nginx/errors;
}
server {
...
}
server {
...
}
...
}
I've tried setting:
http {
...
root /var/www/nginx/errors; # also with root /var/www/nginx
...
}
with no success: always showing nginx default error page.
Is it possible to define a common location for all servers?
No.
You could make separate file and include
it into all your servers.
/etc/nginx/error-location.inc:
location ^~ /error/ {
internal;
root /var/www/nginx/errors;
}
And then:
server {
...
include error-location.inc;
}
server {
...
include error-location.inc;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With