Skip to content

Commit 20dcf84

Browse files
nginx template: allow /.well-known/* (the runtime-generated config)
PR #9 fixed default.conf and default-rootless.conf — the static, baked- into-image versions. But the running container generates its config from default.conf.template via envsubst at startup, overwriting the baked default.conf with the templated output. The fix needs to live on the template path or it never reaches running pods. Verified live: a fresh id pod showed the correct `location ^~ /.well-known/` in default.conf (baked) but a regenerated runtime default.conf without the block. /.well-known/openid-configuration remained 404. Adding the well-known allow to the template, with ${NGINX_TRY_FILES} for the framework's index target, so the runtime config gets it. Build-and-push needs another workflow_dispatch since the workflow doesn't auto-trigger on path changes.
1 parent 063e8a3 commit 20dcf84

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

php-fpm-nginx/common/default.conf.template

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ ${NGINX_SECURITY_HEADERS}
176176
# SECURITY: Block sensitive files and directories
177177
# ─────────────────────────────────────────────────────────────────────────
178178

179+
# RFC 8615 — /.well-known/ is the reserved namespace for site-wide
180+
# service metadata: OIDC discovery, OAuth authorization-server
181+
# metadata, security.txt, ACME challenges, change-password, etc.
182+
# Apps register handlers (e.g. Laravel: `Route::get('.well-known/...')`),
183+
# but the catch-all dotfile block below would otherwise 404 every
184+
# request before the app sees it.
185+
#
186+
# `^~` makes this a prefix match that wins over the regex catch-all
187+
# below — nginx prefers `^~` matches and skips regex evaluation
188+
# when one matches. Place BEFORE the `/\.` block; ordering of
189+
# regex blocks matters but `^~` short-circuits regardless.
190+
location ^~ /.well-known/ {
191+
try_files $uri $uri/ ${NGINX_TRY_FILES};
192+
}
193+
179194
# Block hidden files (.env, .git, .htaccess, .svn, etc.)
180195
location ~ /\.(env|git|svn|htaccess|htpasswd|gitignore|gitattributes|dockerignore) {
181196
deny all;

0 commit comments

Comments
 (0)