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

More Nginx tasks

Back to the full Nginx cheat sheet