Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable redirection of HTTP requests to HTTPS #253

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Jan 21, 2025

Using Django's SECURE_SSL_REDIRECT:
https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-SECURE_SSL_REDIRECT

Also configures gunicorn's forwarded_allow_ips setting to "*" so that gunicorn trusts the X-Forwarded-Proto header set by the Heroku Router during TLS termination, to ensure that HTTPS requests are correctly marked as secure in the WSGI metadata passed to the WSGI app (in this case, Django). See:
https://docs.gunicorn.org/en/stable/settings.html#forwarded-allow-ips
https://devcenter.heroku.com/articles/http-routing#heroku-headers

(Whilst the classic Python buildpack already configures this by setting the env var FORWARDED_ALLOW_IPS, the Python CNB doesn't yet do so, and it's clearer to have the config explicitly set in the app source.)

GUS-W-17482732.

Using Django's `SECURE_SSL_REDIRECT`:
https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-SECURE_SSL_REDIRECT

Also configures gunicorn's `forwarded_allow_ips` setting to `"*"` so that
gunicorn trusts the `X-Forwarded-Proto` header set by the Heroku Router during
TLS termination, to ensure that HTTPS requests are correctly marked as secure in
the WSGI metadata passed to the WSGI app (in this case, Django). See:
https://docs.gunicorn.org/en/stable/settings.html#forwarded-allow-ips
https://devcenter.heroku.com/articles/http-routing#heroku-headers

(Whilst the classic Python buildpack already configures this by setting the env
var `FORWARDED_ALLOW_IPS`, the Python CNB doesn't yet do so, and it's
clearer to have the config explicitly set in the app source.)

GUS-W-17482732.
@edmorley edmorley self-assigned this Jan 21, 2025
@edmorley edmorley requested a review from a team as a code owner January 21, 2025 22:59
@edmorley edmorley removed the request for review from a team January 21, 2025 22:59
@heroku heroku bot temporarily deployed to getting-star-edmorley-e-03q7hl January 21, 2025 22:59 Inactive
@edmorley edmorley merged commit a75e1c5 into main Jan 21, 2025
1 check passed
@edmorley edmorley deleted the edmorley/enable-https-redirection branch January 21, 2025 23:06
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