On 2/22/13 12:42 PM, Alexander Nestorov wrote:
Example:
It would be really usefull (in my particular case) to set error_page
to some absolute path so that all server{}
get error_page automatically. Then, if my domain 42 needs a custom
error_page I could just add the error_page
to that server{} and it will get overriden.
Alexander,
I think I achieved what you're after:
- default 403, 404 and 503 error pages in /usr/local/share/www/
- custom 404, 404 and 504 error pages for each vhost in $document_root/
Typically, a vhost in /etc/nginx/sites-available/some.domain.org
includes vhost.conf which includes errors.conf
Tell me if that helps.
Feedback from others appreciated!
Gregory
error.conf:
error_page 403 @403;
error_page 404 @404;
error_page 503 @503;
location @403 {
try_files /403.html @403_fallback;
}
location = /403.html {
if (-f $document_root/offline) {
error_page 503 @offline;
return 503;
}
return 404;
}
location @403_fallback {
root /usr/local/share/www;
try_files /403.html =403;
}
location @404 {
try_files /404.html @404_fallback;
}
location = /404.html {
if (-f $document_root/offline) {
error_page 503 @offline;
return 503;
}
return 404;
}
location @404_fallback {
root /usr/local/share/www;
try_files /404.html =404;
}
location @503 {
try_files /503.html @503_fallback;
}
location = /503.html {
if (-f $document_root/offline) {
error_page 503 @offline;
return 503;
}
return 404;
}
location @503_fallback {
root /usr/local/share/www;
try_files /50x.html =503;
}
---
offline.conf
location @offline {
try_files /offline.html @503;
}
location = /offline {
if (-f $document_root/offline) {
error_page 503 @offline;
return 503;
}
return 404;
}
location = /offline.html {
if (-f $document_root/offline) {
error_page 503 @offline;
return 503;
}
return 404;
}
----
vhost.conf
include errors.conf;
include offline.conf;
location / {
if (-f $document_root/offline) {
error_page 503 @offline;
return 503;
}
try_files $uri $uri/ /index.php;
}
--
___________________________________________________________________
IRCNet /msg guardian | [email protected] | Twitter @planetdnews
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx