[add] add custom error page if upstream fails
This commit is contained in:
@@ -151,6 +151,8 @@ function gen_server_config()
|
||||
server {
|
||||
listen 8443 ssl;
|
||||
|
||||
error_page 502 503 504 @error;
|
||||
|
||||
# prevent redirecting to 8080 port
|
||||
# (e.g. when trailing slash is missed)
|
||||
port_in_redirect off;
|
||||
@@ -159,13 +161,13 @@ function gen_server_config()
|
||||
|
||||
ssl_certificate /service/ssl/$root_domain/fullchain.pem;
|
||||
ssl_certificate_key /service/ssl/$root_domain/privkey.pem;
|
||||
set \$upstream $server;
|
||||
|
||||
location / {
|
||||
# allow for upstream to be offline by setting
|
||||
# docker dns resolver and a variable for the server
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
set \$web_$rng_number $server;
|
||||
proxy_pass http://\$web_$rng_number:8080;
|
||||
proxy_pass http://\$upstream:8080;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host \$host;
|
||||
@@ -173,6 +175,36 @@ function gen_server_config()
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host \$server_name;
|
||||
}
|
||||
|
||||
location /0x90 {
|
||||
ssi on;
|
||||
error_page 502 503 504 404 @error;
|
||||
# 403 needs to be on its own, get default 503 otherwise
|
||||
error_page 403 /0x90/errors/error_403.html;
|
||||
# set alias (instead of root) to not append /0x90 to path
|
||||
include /etc/nginx/mime.types;
|
||||
alias /service/html;
|
||||
}
|
||||
location ~/0x90/?$ { error_page 404 @error; deny all; return 404; }
|
||||
location ~/0x90/css/?$ { error_page 404 @error; deny all; return 404; }
|
||||
location ~/0x90/fonts/?$ { error_page 404 @error; deny all; return 404; }
|
||||
location /0x90/errors { error_page 404 @error; deny all; return 404; }
|
||||
location /0x90/check { error_page 404 @error; deny all; return 404; }
|
||||
|
||||
location @error {
|
||||
root /service/html;
|
||||
internal;
|
||||
# replace variables in html
|
||||
ssi on;
|
||||
try_files
|
||||
|
||||
/errors/error_\$status.html
|
||||
/errors/error_\${status_prefix}x.html
|
||||
/errors/error_\${status_category}xx.html
|
||||
/errors/error.html;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user