A comprehensive guide to installing and configuring SSL certificates on Nginx web servers.
Before installing an SSL certificate on Nginx, ensure you have:
You can obtain an SSL certificate through several methods:
Follow these steps to install your SSL certificate:
sudo mkdir -p /etc/nginx/ssl/example.com
sudo cp example.com.crt /etc/nginx/ssl/example.com/
sudo cp example.com.key /etc/nginx/ssl/example.com/
sudo cp chain.crt /etc/nginx/ssl/example.com/
sudo chmod 600 /etc/nginx/ssl/example.com/*
Use our configuration generator to create your Nginx SSL configuration:
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/nginx/ssl/example.com/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/example.com.key;
ssl_trusted_certificate /etc/nginx/ssl/example.com/chain.crt;
# Modern SSL configuration
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:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
root /var/www/html;
index index.html;
}
}
Verify your SSL configuration:
sudo nginx -t
sudo systemctl reload nginx
Use Certbot for automated SSL management:
# Install Certbot
sudo apt update
sudo apt install certbot python3-certbot-nginx
# Obtain and install certificate
sudo certbot --nginx -d example.com
# Auto-renewal test
sudo certbot renew --dry-run
Certellix is an independent service. We are not affiliated with any commercial certificate authority.