Enable SECURE_PROXY_SSL_HEADER on TEST/PROD (#1329)#1336
Merged
Conversation
Behind UW CSE's TLS-terminating Apache proxy, the Django container is reached over plain HTTP, so request.scheme reported "http" and request.is_secure() was False even though visitors arrive over HTTPS. Apache now sets X-Forwarded-Proto: https on test and prod (confirmed by UW CSE IT), and the backend binds to loopback only, so the header can't be spoofed by a direct client. Trust it via SECURE_PROXY_SSL_HEADER, gated to DJANGO_ENV in (PROD, TEST) — local dev has no such proxy and must not trust a client-supplied header. This is the framework-level fix behind #1236. The in-app site_scheme workaround is left in place for now and will be removed in a follow-up once verified on -test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1329.
What
Adds, gated to the deployed environments:
Behind UW CSE's TLS-terminating Apache proxy the Django container is reached over plain HTTP, so
request.schemereportedhttpandrequest.is_secure()wasFalseeven though visitors arrive over HTTPS. This tells Django to trust the proxy'sX-Forwarded-Protoheader as the real scheme.Why it's safe (and why gated)
X-Forwarded-Proto: httpson both test and prod.DJANGO_ENV in (PROD, TEST)— local dev has no trusted proxy, so we must not trust a client-supplied header there. Mirrors theDJANGO_ENV-keyed pattern from Project page social media (opengraph) not working perfectly #1236.Scope
This is the framework-level fix behind #1236. The in-app
site_schemeworkaround (context processor +website/utils/metadata.py+ templates) is left in place for now as a redundant safety net; it will be removed in a follow-up oncerequest.is_secure()is verified correct on-test.Testing
No new automated test: the behavior is Django framework internals (
SECURE_PROXY_SSL_HEADER) gated by an import-time env var, so a regression test would only re-test Django. Existingtest_page_metadata.pysite_schemetests remain green (workaround untouched).Manual verification after merge → deploy to
-test:og:urltags still renderhttps://(no regression).request.is_secure()is nowTruebehind the proxy.🤖 Generated with Claude Code