Question

App Platform Django SECURE_PROXY_SSL_HEADER use

I have a Django 4.2 app running on App Platform. When inspecting request headers in my app I can see that they include HTTP_X_FORWARDED_PROTO: https. That’s good and implies that I should be able to add a SECURE_PROXY_SSL_HEADER to my security settings. However, the Django documentation for that setting includes the following warning:

Modifying this setting can compromise your site’s security. Ensure you fully understand your setup before changing it.

Make sure ALL of the following are true before setting this…:

  • Your Django app is behind a proxy.
  • Your proxy strips the X-Forwarded-Proto header from all incoming requests, even when it contains a comma-separated list of protocols. In other words, if end users include that header in their requests, the proxy will discard it.
  • Your proxy sets the X-Forwarded-Proto header and sends it to Django, but only for requests that originally come in via HTTPS.

So, I would like to know if App Platform meets all three of those conditions.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey Siburg 👋,

To address your concerns regarding the three conditions listed in Django’s documentation:

  • Yes, your Django app is behind a proxy when using App Platform. DigitalOcean uses a managed load balancer to route requests to your application, which acts as a reverse proxy.

  • DigitalOcean’s App Platform ensures that the X-Forwarded-Proto header is only set by the proxy. This means it strips any existing X-Forwarded-Proto headers that might be included in the original request, so you can safely assume that the header being passed to your app is set by the App Platform itself and not from external sources.

  • Yes, the App Platform sets the X-Forwarded-Proto: https header only for requests that originally come in via HTTPS. This ensures that Django knows the request was originally over HTTPS, even though it arrives at your app via HTTP from the proxy.

Hope that this helps!

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.