From cb471f9ca8b7fd1757eaf3f3ddb226b8ecc030fd Mon Sep 17 00:00:00 2001 From: Casey Rapnicki Date: Thu, 9 Jan 2025 17:38:37 -0500 Subject: [PATCH] DIGITAL-90: Configure 404 page. --- .../nginx-waf/nginx/conf.d/default.conf | 56 ++----------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/terraform/applications/nginx-waf/nginx/conf.d/default.conf b/terraform/applications/nginx-waf/nginx/conf.d/default.conf index c963315a..b0d22ccc 100644 --- a/terraform/applications/nginx-waf/nginx/conf.d/default.conf +++ b/terraform/applications/nginx-waf/nginx/conf.d/default.conf @@ -3,11 +3,6 @@ # '' close; # } -# map $request_uri $error_page { -# default /404/index.html; -# ~/(?[a-z][a-z]?[a-z]|zh-hans)/(.*) /$lang/404/index.html; -# } - server { server_name _; listen $VCAP_APP_PORT; @@ -16,9 +11,6 @@ server { modsecurity_rules_file /home/vcap/app/nginx/snippets/owasp-modsecurity-main.conf; set $cf_forwarded_host "$host"; - #if ($http_x_cf_forwarded_url ~* ^(https?\:\/\/)(.*?)(\/(.*))?$) { - # set $cf_forwarded_host "$2"; - #} set $port 8881; if ($cf_forwarded_host ~* \-drupal\-) { @@ -28,7 +20,7 @@ server { location @fourohfour { allow all; access_log off; - + default_type text/html; rewrite ^ /404/index.html; include nginx/snippets/proxy-to-static.conf; @@ -66,13 +58,7 @@ server { listen 8881; location @fourohfour { - allow all; - access_log off; - - default_type text/html; - rewrite ^ /404/index.html; - include nginx/snippets/proxy-to-static.conf; - break; + return 404; } location / { @@ -83,7 +69,7 @@ server { #include nginx/dynamic/deny-by-domain.conf; # include nginx/snippets/ip-restrict-static.conf; include nginx/snippets/proxy-to-static.conf; - error_page 403 404 =404 @fourohfour; + error_page 403 = @fourohfour; } } @@ -94,7 +80,6 @@ server { error_page 403 = @forbidden; location @forbidden { - allow all; access_log off; @@ -220,13 +205,7 @@ server { rewrite ^/s3/files/(.*)$ /cms/public/$1 break; location @fourohfour { - allow all; - access_log off; - - default_type text/html; - rewrite ^ /404/index.html; - include nginx/snippets/proxy-to-static.conf; - break; + return 404; } location / { @@ -237,31 +216,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 404 =404 @fourohfour; - } -} - -server { - server_name 127.0.0.1; - listen 8884; - - - location @fourohfour { - allow all; - access_log off; - - default_type text/html; - rewrite ^ /404/index.html; - include nginx/snippets/proxy-to-static.conf; - break; - } - - location / { - rewrite ^/static/(.*) /$1; - rewrite ^([^.]*[^/])$ $1/; - rewrite (.*)/$ $1/index.html last; - - include nginx/snippets/proxy-to-static.conf; - error_page 403 404 =404 @fourohfour; + error_page 403 = @fourohfour; } }