SSL/TLS Configuration in Nginx
From the Nginx cheat sheet ยท Server Blocks & Virtual Hosts ยท verified Jul 2026
SSL/TLS Configuration
Configuring HTTPS with SSL certificates
nginx
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
# Redirect HTTP to HTTPS
location / {
root /var/www/example.com;
}
}๐ Always use HTTPS in production
๐ Let's Encrypt for free SSL certificates
โก HTTP/2 for better performance
๐ HSTS header for forcing HTTPS