Installing an SSL Certificate on the modern (> 0.7.14) nginx platform is quite easy.
- Locate the server block for your website.
- Add a listen directive for your secure port and add the ssl
- Add the ssl_certificate directive; the parameter is the full path to the nginx format of your certificate.
- Add the ssl_certificate_key directive; the parameter is the full path to your private key.
Example:
server {
listen 80;
listen [::]:80;
server_name nginx.w3services.net;
return 301 https://$server_name$request_uri;
}
server
{
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name nginx.w3services.net;
root /var/www/html;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl_path/server.crt;
ssl_certificate_key /etc/nginx/ssl_path/key.key;
}