From 51610aa06cc22c3fbd74b4237ff3e59481ce61dc Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:21:11 +0000 Subject: [PATCH] CDPT-2264 Improve nginx's file serving. Previously a missing file caused an error. Now it's a 404 without an error. --- deploy/config/local/nginx/server.conf | 10 ++++++++-- deploy/config/server.conf | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/deploy/config/local/nginx/server.conf b/deploy/config/local/nginx/server.conf index 3559ea15f..aef7686c6 100644 --- a/deploy/config/local/nginx/server.conf +++ b/deploy/config/local/nginx/server.conf @@ -71,8 +71,14 @@ server { # Empty location blocks to allow access when "/" location # sends an HTTP 503 during maintenance mode - location /app/themes/clarity/error-pages/ { } - location /app/themes/clarity/dist/ { } + location /app/themes/clarity/error-pages/ { + # If the file exists, serve it directly, else return 404. + try_files $uri =404; + } + location /app/themes/clarity/dist/ { + # If the file exists, serve it directly, else return 404. + try_files $uri =404; + } # Rewrite old upload URLs to the bedrock equivalent location /wp-content/uploads/ { diff --git a/deploy/config/server.conf b/deploy/config/server.conf index 49a3b974d..3d3c29d09 100644 --- a/deploy/config/server.conf +++ b/deploy/config/server.conf @@ -90,8 +90,14 @@ server { # Empty location blocks to allow access when "/" location # sends an HTTP 503 during maintenance mode - location /app/themes/clarity/error-pages/ { } - location /app/themes/clarity/dist/ { } + location /app/themes/clarity/error-pages/ { + # If the file exists, serve it directly, else return 404. + try_files $uri =404; + } + location /app/themes/clarity/dist/ { + # If the file exists, serve it directly, else return 404. + try_files $uri =404; + } # Rewrite old upload URLs to the bedrock equivalent location /wp-content/uploads/ {