Skip to content

Commit 78521e0

Browse files
DIGITAL-90: Configure 404 page.
1 parent 80117ac commit 78521e0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

terraform/applications/nginx-waf/nginx/conf.d/default.conf

+12-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ map $request_uri $error_page {
77
default /404/index.html;
88
}
99

10+
map $uri $custom_content_type {
11+
default "text/html";
12+
~(.*.ico)$ "image/x-icon";
13+
}
14+
1015
server {
1116
server_name _;
1217
listen $VCAP_APP_PORT;
@@ -31,7 +36,6 @@ server {
3136
proxy_set_header Host $cf_forwarded_host;
3237
proxy_set_header X-Forwarded-For $remote_addr;
3338
proxy_set_header X-Real-IP $remote_addr;
34-
error_page 403 404 =404 @fourohfour;
3539
}
3640

3741
location / {
@@ -43,7 +47,6 @@ server {
4347
proxy_set_header Host $cf_forwarded_host;
4448
proxy_set_header X-Forwarded-For $remote_addr;
4549
proxy_set_header X-Real-IP $remote_addr;
46-
error_page 403 404 =404 @fourohfour;
4750
}
4851
}
4952

@@ -57,17 +60,19 @@ server {
5760

5861
rewrite ^ $error_page;
5962

60-
proxy_hide_header Content-Type;
61-
add_header Content-Type 'text/html';
62-
6363
include nginx/snippets/proxy-to-static.conf;
64+
65+
proxy_hide_header Content-Type;
66+
add_header Content-Type $custom_content_type;
67+
68+
break;
6469
}
6570

6671
location = /favicon.ico {
6772
log_not_found off;
6873
access_log off;
6974
}
70-
75+
7176
location / {
7277
rewrite ^([^.]*[^/])$ $1/;
7378
rewrite (.*)/$ $1/index.html last;
@@ -222,6 +227,6 @@ server {
222227
#include nginx/dynamic/deny-by-domain.conf;
223228
# include nginx/snippets/ip-restrict-static.conf;
224229
include nginx/snippets/proxy-to-storage.conf;
225-
error_page 403 = @fourohfour;
230+
error_page 403 404 =404 @fourohfour;
226231
}
227232
}

0 commit comments

Comments
 (0)