I learned how to get NGINX to return 503 customer error pages,
but I cannot find out how to do the following:
Sample config file:
lo
The below configuration works for close to the latest stable nginx 1.2.4.
I could not find a way to enable a maintenance page with out using an if but apparently according to IfIsEvil it is an ok if.
touch /srv/sites/blah/public/maintenance.enable. You can rm the file to disable.502 will be mapped to 503 which is what most people want. You don't want to give Google a 502.502 and 503 pages. Your app will generate the other error pages.There are other configurations on the web but they didn't seem to work on the latest nginx.
server {
listen 80;
server_name blah.com;
access_log /srv/sites/blah/logs/access.log;
error_log /srv/sites/blah/logs/error.log;
root /srv/sites/blah/public/;
index index.html;
location / {
if (-f $document_root/maintenance.enable) {
return 503;
}
try_files /override.html @tomcat;
}
location = /502.html {
}
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
error_page 503 @maintenance;
error_page 502 =503 /502.html;
location @tomcat {
client_max_body_size 50M;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-Proto http;
proxy_pass http://tomcat;
proxy_redirect off;
}
}