Skip to content

Commit

Permalink
Merge pull request #1434 from USEPA/nginx-fast-404
Browse files Browse the repository at this point in the history
Return HTTP 410 for now-removed search paths
  • Loading branch information
carsoncho authored Aug 6, 2024
2 parents 2349e3c + 9e7a76b commit 8fb269f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions services/drupal/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,49 @@ server {
rewrite ^/(.*)$ /index.php?q=$1;
}

# On any nginx 404, use this internal path
error_page 404 /_404;

# Set up nginx's 404 machinery to return fast-404.html anytime nginx process a 404
location = /_404 {
# Internal means /_404 can't be visited from outside
internal;

# Return the contents of fast-404.html
root /var/www/html/web/themes/epa_theme/source;
try_files /fast-404.html =404;
}

# For each listed path, return HTTP 410 Gone, using our 404 template instead:
# users will see a "page not found" page, but code will see a "this page will
# never return" status code. Hopefully this will defray some of the ongoing
# load.
location ^~ /newsreleases/search/ {
error_page 410 /_404;
return 410;
}

location ^~ /faqs/search/ {
error_page 410 /_404;
return 410;
}

location ^~ /publicnotices/notices-search/ {
error_page 410 /_404;
return 410;
}

location ^~ /perspectives/search/ {
error_page 410 /_404;
return 410;
}

location ^~ /speeches/search/ {
error_page 410 /_404;
return 410;
}


# This prevents nginx's view of the filesystem from conflicting with the Drupal node of
# the same name.
location = /libraries {
Expand Down

0 comments on commit 8fb269f

Please sign in to comment.