Skip to content

fix(url): trust X-Forwarded-Proto for site URL scheme#51

Merged
bigin merged 1 commit into
masterfrom
fix/trust-x-forwarded-proto
May 15, 2026
Merged

fix(url): trust X-Forwarded-Proto for site URL scheme#51
bigin merged 1 commit into
masterfrom
fix/trust-x-forwarded-proto

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 15, 2026

Both Site::detectSiteUrl and Editor::detectSiteUrl looked only at $_SERVER['HTTPS'], which is unset when PHP sits behind a TLS-terminating reverse proxy (nginx-proxy, traefik, …). Result: every absolute URL the templates emit (asset hrefs, form actions, navigation links) was http:// even though the page itself was served over https — every modern browser blocks the assets as Mixed Content.

Now both check HTTP_X_FORWARDED_PROTO first, falling back to the $_SERVER['HTTPS'] heuristic. First value wins for chained proxies ('https,http') so a downstream http hop can't downgrade the scheme.

Verified by hitting https://demos.scriptor-cms.dev (nginx-proxy + acme-companion on Hetzner) — no more Mixed Content warnings.

Both Site::detectSiteUrl and Editor::detectSiteUrl looked only at
$_SERVER['HTTPS'], which is unset when PHP sits behind a TLS-terminating
reverse proxy (nginx-proxy, traefik, …). Result: every absolute URL
the templates emit (asset hrefs, form actions, navigation links) was
http:// even though the page itself was served over https — every
modern browser blocks the assets as Mixed Content.

Now both check HTTP_X_FORWARDED_PROTO first, falling back to the
$_SERVER['HTTPS'] heuristic. First value wins for chained proxies
('https,http') so a downstream http hop can't downgrade the scheme.

Verified by hitting https://demos.scriptor-cms.dev (nginx-proxy +
acme-companion on Hetzner) — no more Mixed Content warnings.
@bigin bigin merged commit 5068851 into master May 15, 2026
@bigin bigin deleted the fix/trust-x-forwarded-proto branch May 15, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant