nginx error_page for 502 Bad Gateway errors
Here is my server configuration:
server {
listen 0.0.0.0;
server_name dev.host.com; location / {
include /etc/nginx/proxy.conf;
proxy_pass http://127.0.0.1:5000;
proxy_redirect default; error_page 502 =200 @maintenance;
} location ^~ /(img|js|css)/ {
root /path/to/application/assets;
expires max;
break; error_page 404 =302 /;
} location @maintenance {
root /path/to/static/offline/files;
try_files $uri $uri/ /index.html =503;
}
}
When the upstream app is not online, I am getting the default nginx 502 page for the root path (that is: GET /). Any idea why this is happening? I’d like the root path to respond with the maintenance page just like any other request path.
The devils in the details; my @maintenance named location was not setup correctly. Specifically, the send argument ($uri/) to try_files was causing the problem. Here is the correct named location:
location @maintenance {
root /path/to/static/offline/files;
try_files $uri /index.html =503;
}
Check more discussion of this question.
No related posts.
Leave a comment
Recent Posts
- Cron expression that runs every 5 minutes from 1:30 am – 6:00 am [duplicate]
- Understanding redundant power supplies
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





