Nginx SSL Installation
For Nginx Web Server.
Files
- Full-chain PEM file:
domain.pem - Private Key:
domain.key
Recommended location:
text
/etc/ssl/example.com/Example
nginx
server {
listen 443 ssl http2;
server_name example.com www.example.com;
root /var/www/example.com/public;
index index.html index.php;
ssl_certificate /etc/ssl/example.com/domain.pem;
ssl_certificate_key /etc/ssl/example.com/domain.key;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}TIP
The old ssl on; directive is deprecated. Use listen 443 ssl; instead.
Reload
bash
sudo nginx -t
sudo systemctl reload nginx