Topic · Serving the app

HTTPS, TLS & DNS for Django in production

Domains, certificates, redirects, and the settings that make Django agree with its proxy about HTTPS.

a name, a certificate, a redirectDNSA / AAAA recordsServer IPport 80 and 443CertificateLet's EncryptHTTPSredirect, HSTSDjangoknows it is HTTPSThe last box is the one most often forgotten: the proxy SSL header

A production site needs a domain that points at it, a valid certificate, and a Django configuration that knows the request arrived over HTTPS. The last part is the one most often missed.

The guides cover DNS records, Let’s Encrypt and renewals, CDNs such as Cloudflare in front, and the errors that appear when any link in that chain breaks.

8Set it up
2Run it well
2Check it
19Fix it

Set it up

Guides that take this from nothing to running in production.

  • Configure HTTPS for Django with Let's Encrypt

    A Django app running over plain HTTP is not safe for production. Login sessions, admin access, CSRF tokens, API traffic, and password resets can all be exposed in transit if TLS...

  • Point a Domain at Your Django Server (DNS Setup)

    Connect a domain to a Django server: A and AAAA records, www and apex, CNAMEs for platforms, TTLs, verifying propagation with dig, and matching ALLOWED_HOSTS and certificates.

  • Get a Wildcard Certificate for Django Subdomains

    Issue a Let’s Encrypt wildcard certificate for *.example.com to serve Django on many subdomains: DNS-01 challenges with certbot DNS plugins or acme.sh, automatic renewal with provider API tokens, Nginx configuration, and Django host settings.

  • Custom Domains With Automatic HTTPS for Django Tenants

    Let SaaS customers point their own domains at a multi-tenant Django app with automatic HTTPS: Caddy on-demand TLS with an ask endpoint in Django, domain verification, tenant lookup by Host, and protecting against abuse and rate limits.

  • Deploy Django with Caddy and Automatic HTTPS

    If you want to deploy Django with Caddy in production, the main challenge is not just putting a reverse proxy in front of the app.

  • Deploy Django Behind Cloudflare

    Put Django behind Cloudflare correctly: Full (strict) TLS, origin lockdown, real client IPs, HTTPS detection, cache rules, and request limits.

  • Expose Django with Cloudflare Tunnel

    Serve a Django app through Cloudflare Tunnel with no open inbound ports: cloudflared setup, ingress rules, DNS routing, real client IPs, HTTPS settings, and protecting the admin.

  • Automate HTTPS for Django on Kubernetes With cert-manager

    Use cert-manager to issue and renew Let’s Encrypt certificates for a Django app on Kubernetes: install it with Helm, create a ClusterIssuer with HTTP-01 or DNS-01, request certificates through Ingress or Gateway annotations, and troubleshoot stuck challenges.

Run it well

Tuning, reliability, and operations once it works.

  • Harden Nginx TLS for Django (SSL Labs A+)

    Configure Nginx TLS for a Django site to earn an SSL Labs A+: TLS 1.2 and 1.3 only, modern ciphers, HSTS with Django settings, OCSP stapling, session settings, certificate chain, and verifying with SSL Labs and testssl.sh.

  • Monitor TLS Certificate Expiry for Django Sites

    Catch expiring HTTPS certificates before users do: check expiry from outside with uptime monitors, Prometheus blackbox exporter, or a scheduled script, cover every domain and certificate path, alert at 21 and 7 days, and verify that renewal actually reloads Nginx.

Check it

Review lists to run before launch or after a change.

  • DNS Cutover Checklist for Moving a Django Site

    A checklist for switching DNS when moving a Django site to a new server, host, or CDN: lower TTLs in advance, prepare TLS certificates and ALLOWED_HOSTS, sync data and freeze writes, switch records, verify from several locations, and keep the old host as a fallback.

  • Django Security Headers Checklist

    Check every HTTP security header a Django site should send: HSTS, CSP, frame options, nosniff, referrer and permissions policies, COOP, and cookie flags.

Fix it

Errors and symptoms, each traced to a cause and a fix.

Learning paths through this topic

Related topics