Modified 404/500 error
This commit is contained in:
+16
-20
@@ -20,11 +20,18 @@ http {
|
||||
|
||||
map $status $error_title {
|
||||
default "Service Unavailable";
|
||||
404 "Not Found";
|
||||
500 "Internal Server Error";
|
||||
502 "Bad Gateway";
|
||||
503 "Service Unavailable";
|
||||
504 "Gateway Timeout";
|
||||
}
|
||||
|
||||
map $status $error_message {
|
||||
default "We're working to resolve the issue.<br />Please try again shortly.";
|
||||
404 "The page you're looking for could not be found.";
|
||||
}
|
||||
|
||||
include /etc/nginx/upstreams.map;
|
||||
|
||||
server {
|
||||
@@ -40,7 +47,7 @@ http {
|
||||
return 200 "ok\n";
|
||||
}
|
||||
|
||||
error_page 502 503 504 /__error/index.html;
|
||||
error_page 404 500 502 503 504 /__error/index.html;
|
||||
|
||||
location = /__error/index.html {
|
||||
internal;
|
||||
@@ -48,31 +55,20 @@ http {
|
||||
sub_filter_types text/html;
|
||||
sub_filter "__STATUS__" $status;
|
||||
sub_filter "__ERROR_TITLE__" $error_title;
|
||||
sub_filter "__ERROR_MESSAGE__" $error_message;
|
||||
sub_filter "__HOST__" $host;
|
||||
add_header Cache-Control "no-store" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
}
|
||||
|
||||
# API 404 stays with the app so JSON clients keep working.
|
||||
location /api/ {
|
||||
error_page 500 502 503 504 /__error/index.html;
|
||||
include /etc/nginx/proxy_to_app.conf;
|
||||
}
|
||||
|
||||
location / {
|
||||
if ($app_port = 0) {
|
||||
return 502;
|
||||
}
|
||||
|
||||
proxy_pass http://127.0.0.1:$app_port;
|
||||
proxy_http_version 1.1;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
proxy_connect_timeout 3s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_read_timeout 3600s;
|
||||
|
||||
# Only replace DSM-style "upstream down" pages. App 404/500 stay as-is.
|
||||
proxy_intercept_errors on;
|
||||
include /etc/nginx/proxy_to_app.conf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user