From 78521e079f519af0cd21ffbe45478f030f496455 Mon Sep 17 00:00:00 2001 From: Casey Rapnicki Date: Thu, 16 Jan 2025 18:57:15 -0500 Subject: [PATCH] DIGITAL-90: Configure 404 page. --- .../nginx-waf/nginx/conf.d/default.conf | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/terraform/applications/nginx-waf/nginx/conf.d/default.conf b/terraform/applications/nginx-waf/nginx/conf.d/default.conf index 13b73f10..9445a53d 100644 --- a/terraform/applications/nginx-waf/nginx/conf.d/default.conf +++ b/terraform/applications/nginx-waf/nginx/conf.d/default.conf @@ -7,6 +7,11 @@ map $request_uri $error_page { default /404/index.html; } +map $uri $custom_content_type { + default "text/html"; + ~(.*.ico)$ "image/x-icon"; +} + server { server_name _; listen $VCAP_APP_PORT; @@ -31,7 +36,6 @@ server { proxy_set_header Host $cf_forwarded_host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; - error_page 403 404 =404 @fourohfour; } location / { @@ -43,7 +47,6 @@ server { proxy_set_header Host $cf_forwarded_host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; - error_page 403 404 =404 @fourohfour; } } @@ -57,17 +60,19 @@ server { rewrite ^ $error_page; - proxy_hide_header Content-Type; - add_header Content-Type 'text/html'; - include nginx/snippets/proxy-to-static.conf; + + proxy_hide_header Content-Type; + add_header Content-Type $custom_content_type; + + break; } location = /favicon.ico { log_not_found off; access_log off; } - + location / { rewrite ^([^.]*[^/])$ $1/; rewrite (.*)/$ $1/index.html last; @@ -222,6 +227,6 @@ server { #include nginx/dynamic/deny-by-domain.conf; # include nginx/snippets/ip-restrict-static.conf; include nginx/snippets/proxy-to-storage.conf; - error_page 403 = @fourohfour; + error_page 403 404 =404 @fourohfour; } }