Interview Prep/Networking/TLS, HTTP & Application Layer

Your site must redirect all HTTP traffic to HTTPS. How do you do it?

BeginnerScenarioTLS, HTTP & Application Layer
Answer

Situation read → A simple but common task, with a security extra.

What I'd do →

  1. On the ALB add a listener on port 80 with a redirect action to HTTPS 443 and status HTTP_301
  2. On Nginx use server { listen 80; return 301 https://$host$request_uri; }
  3. Add HSTS on the HTTPS side: add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  4. Test with curl -sI http://example.com

Why → A redirect protects the first request; HSTS makes browsers skip HTTP afterward.

Interview tip → Say you start HSTS with a short max-age before enabling preload.

All Networking questions Roadmap: Networking for DevOps

More on TLS, HTTP & Application Layer