From dd1f20fc0a82101a574860ddfdf24593ee423fce Mon Sep 17 00:00:00 2001 From: robert dennis <31261583+robertdrakedennis@users.noreply.github.com> Date: Tue, 6 Oct 2026 14:05:32 -0400 Subject: [PATCH] nginx tweaks --- .github/docker/default.conf | 12 +++++++++--- .github/docker/default_ssl.conf | 18 ++++++++++++++---- .github/docker/entrypoint.sh | 5 +++++ .github/docker/smoke-test.sh | 2 +- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/docker/default.conf b/.github/docker/default.conf index 34a16a47a..213733d24 100644 --- a/.github/docker/default.conf +++ b/.github/docker/default.conf @@ -31,9 +31,8 @@ server { } # Extension files are third-party content on the panel's origin. The sandbox stops a - # file opened directly (an SVG, say) from running script as the panel; scripts the - # panel imports are unaffected. ^~ skips the regex locations above, so dotfiles are - # denied again here. + # file opened directly (an SVG, say) from running script as the panel. ^~ skips the + # regex locations above, so dotfiles are denied again here. location ^~ /assets/extensions/ { add_header Content-Security-Policy "sandbox" always; add_header X-Content-Type-Options nosniff always; @@ -42,6 +41,13 @@ server { deny all; } + # A sandbox policy would stop these from starting as workers, and a script never + # renders as a page, so it only needs nosniff. + location ~ \.m?js$ { + add_header X-Content-Type-Options nosniff always; + try_files $uri =404; + } + try_files $uri =404; } diff --git a/.github/docker/default_ssl.conf b/.github/docker/default_ssl.conf index 98d06b4da..b19a9d106 100644 --- a/.github/docker/default_ssl.conf +++ b/.github/docker/default_ssl.conf @@ -63,10 +63,9 @@ server { } # Extension files are third-party content on the panel's origin. The sandbox stops a - # file opened directly (an SVG, say) from running script as the panel; scripts the - # panel imports are unaffected. ^~ skips the regex locations above, so dotfiles are - # denied again here. add_header at this level drops the server-level headers, so - # they are repeated. + # file opened directly (an SVG, say) from running script as the panel. ^~ skips the + # regex locations above, so dotfiles are denied again here. add_header at this level + # drops the server-level headers, so they are repeated. location ^~ /assets/extensions/ { add_header Strict-Transport-Security "max-age=15768000; preload;"; add_header X-Content-Type-Options nosniff always; @@ -78,6 +77,17 @@ server { deny all; } + # A sandbox policy would stop these from starting as workers, and a script never + # renders as a page, so it gets the server-level headers only. + location ~ \.m?js$ { + add_header Strict-Transport-Security "max-age=15768000; preload;"; + add_header X-Content-Type-Options nosniff always; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header Content-Security-Policy "frame-ancestors 'self'"; + try_files $uri =404; + } + try_files $uri =404; } diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index ac974f78f..ca69666fa 100644 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -95,6 +95,11 @@ if ! grep -qF 'location ^~ /assets/extensions/' /etc/nginx/http.d/panel.conf; th deny all; } + location ~ \.m?js$ { + add_header X-Content-Type-Options nosniff always; + try_files $uri =404; + } + try_files $uri =404; } EOF diff --git a/.github/docker/smoke-test.sh b/.github/docker/smoke-test.sh index a7b4667d3..9d8c5bba3 100755 --- a/.github/docker/smoke-test.sh +++ b/.github/docker/smoke-test.sh @@ -208,7 +208,7 @@ PHP version=$(docker exec "$dynamic" cat /app/public/assets/extensions/cache-probe/_current) [[ "$version" =~ ^[a-f0-9]{64}$ ]] docker exec "$dynamic" curl -fsS "http://127.0.0.1/assets/extensions/cache-probe/$version/client.js" | grep -qx "export const smoke = true;" - docker exec "$dynamic" curl -fsSI "http://127.0.0.1/assets/extensions/cache-probe/$version/client.js" | grep -qi '^content-security-policy: sandbox' + docker exec "$dynamic" curl -fsSI "http://127.0.0.1/assets/extensions/cache-probe/$version/client.js" | grep -qi '^x-content-type-options: nosniff' else test "$(docker exec "$dynamic" curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1/api/cache-extension-probe)" = 404 fi