Web Security
Beginner
1 min read
Mixed Content, Certificate Pinning, and HTTPS Best Practices
Example
# nginx configuration: secure HTTPS with best practices
server {
listen 80 default_server;
server_name example.com www.example.com;
# Redirect all HTTP to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# Modern TLS configuration (Mozilla SSL Config Generator — modern profile)
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# Session tickets & OCSP stapling
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_stapling on;
ssl_stapling_verify on;
# HSTS (preload-eligible)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# CAA DNS record (set in your DNS provider):
# example.com. CAA 0 issue "letsencrypt.org"
# example.com. CAA 0 issuewild ";"
location / {
proxy_pass http://app:8000;
}
}
Related Resources
Web Security Reference
Complete tag & property list
Web Security How-To Guides
Step-by-step practical guides
Web Security Exercises
Practice what you've learned
More in Web Security