I'm forwarding requests to a local service through a Nginx server. What I try now to accomplish is to fallback to a local error page in case the service becomes unavailable.
My current configuration is
server {
listen 80;
server_name "";
location / {
proxy_pass http://127.0.0.1:9080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 1;
proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
proxy_intercept_errors on;
}
error_page 501 502 503 @maintenance;
location @maintenance {
root /locust/www/fallback/htdocs;
index index.html index.htm;
}
}
Proxying works, but as soon as I make my service on 9080 unavailable the index.html of my maintenance location is NOT displayed.
Any suggestions on what is wrong with this config?
Actually, I only had to slightly modify your config:
and obviously rename the
index.html
you want to present to500.html
.Try to specify exact url for the error page like: