Configure HSTS Header in nginx
📖 Scenario: You are managing a website server using nginx. To improve security, you want to add the HTTP Strict Transport Security (HSTS) header. This header tells browsers to always use HTTPS when connecting to your site, preventing insecure connections.
🎯 Goal: Configure nginx to send the HSTS header with a max age of 31536000 seconds (1 year) and include subdomains.
📋 What You'll Learn
Create a basic nginx server block for example.com
Add a variable for the HSTS max age value
Add the HSTS header with the max age and includeSubDomains directive
Print the final nginx server block configuration
💡 Why This Matters
🌍 Real World
Web servers use HSTS headers to force browsers to use secure HTTPS connections, protecting users from attacks like man-in-the-middle.
💼 Career
Configuring security headers like HSTS is a common task for DevOps engineers and system administrators to harden web servers.
Progress0 / 4 steps