configuration - Nginx: setting the error page to a static file -
i have following nginx configuration:
server { listen 80; server_name default; location / { proxy_set_header host $host; proxy_pass http://127.0.0.1:8080/; } }
when internal service @ http://127.0.0.1:8080/
not responding nginx return 502 bad gatway error.
my question: how can configure nginx returning static html file, e.g. /var/www/error.html
, when such error occurs?
what tried
taking cue from here tried this:
server { listen 80; server_name default; location / { proxy_set_header host $host; proxy_pass http://127.0.0.1:8080/; } error_page 404 502 /error.html; location = /error.html { internal; root /var/www; } }
it's working fine if service (on port 8080
) down, when service , try access url /error.html
nginx match last location (returning me static file) , avoid it.
well, if don't want expose error page, use named location.
server { listen 80; server_name default; location / { proxy_set_header host $host; proxy_pass http://127.0.0.1:8080/; # need # proxy_intercept_errors on; } error_page 404 502 @error; location @error { root /var/www; try_files /error.html /error.html; } }
Comments
Post a Comment