From 20e91fd89d45ee0dacb19e0214619e84a823f2fc Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Sat, 23 Oct 2021 14:13:13 +0100 Subject: [PATCH] Pre-generate 404 page with initial theme during startup --- data/nginx/server.conf | 19 ++++++++++--------- scripts/entrypoint.sh | 7 +++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/data/nginx/server.conf b/data/nginx/server.conf index 566e560..4bd4056 100644 --- a/data/nginx/server.conf +++ b/data/nginx/server.conf @@ -23,18 +23,19 @@ server { # Add Cache-Control headers for static files, removed in *.php location add_header Cache-Control "public, max-age=7776000, stale-while-revalidate=86400, stale-if-error=604800"; - error_page 404 @not-found; - error_page 502 /errors/502.html; + error_page 404 /errors/generated/404.html; + error_page 502 /errors/static/502.html; - location /errors { + location /errors/ { internal; - alias /etc/nginx/html; - } - location @not-found { - include fastcgi.conf; - fastcgi_cache ERR; - fastcgi_cache_valid 404 1d; + location /errors/static/ { + alias /etc/nginx/html/; + } + + location /errors/generated/ { + alias /app/static/errors/; + } } location @index { diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 6f32da8..b552687 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -223,6 +223,12 @@ collect_static() . static/ } +generate_static() +{ + mkdir -p static/errors + wp eval 'get_template_part("404");' >static/errors/404.html +} + deactivate_missing_plugins() { # Output active plugin entrypoints as a JSON array @@ -299,6 +305,7 @@ case "$1" in setup_components setup_media collect_static + generate_static timestamp "Completed Wordpress preparation" run_background_cron exec "$@" "${extra_args[@]}" -- GitLab