Skip to content

Commit

Permalink
DIGITAL-90: Configure 404 page.
Browse files Browse the repository at this point in the history
  • Loading branch information
casey-rapnicki-bixal committed Jan 16, 2025
1 parent eb8b115 commit 80117ac
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions terraform/applications/nginx-waf/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# map $http_upgrade $connection_upgrade {
# default upgrade;
# '' close;
# }
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

map $request_uri $error_page {
default /404/index.html;
}

server {
server_name _;
Expand All @@ -17,16 +21,6 @@ server {
set $port 8882;
}

location @fourohfour {
allow all;
access_log off;
internal;

default_type text/html;
rewrite ^ /404/index.html break;
include nginx/snippets/proxy-to-static.conf;
}

location ^~ /s3/files {
set $port 8883;
proxy_redirect off;
Expand Down Expand Up @@ -58,18 +52,30 @@ server {
listen 8881;

location @fourohfour {
return 404;
allow all;
access_log off;

rewrite ^ $error_page;

proxy_hide_header Content-Type;
add_header Content-Type 'text/html';

include nginx/snippets/proxy-to-static.conf;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location / {
#rewrite ^/static/(.*) /$1;
rewrite ^([^.]*[^/])$ $1/;
rewrite (.*)/$ $1/index.html last;

#include nginx/dynamic/deny-by-domain.conf;
# include nginx/snippets/ip-restrict-static.conf;
include nginx/snippets/proxy-to-static.conf;
error_page 403 = @fourohfour;
error_page 403 404 =404 @fourohfour;
}
}

Expand Down

0 comments on commit 80117ac

Please sign in to comment.