Saturday, May 12, 2018
Rewrite Http to Https in Nginx
server {
listen 80;
server_name example.com example2.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name example.com example2.com;
...
}
For ssl, usually we need
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/cert/certchain.crt;
ssl_certificate_key /etc/nginx/cert/cert.key;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 60m;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DHE+AES128:!ADH:!AECDH:!MD5;
#ssl_dhparam /etc/nginx/cert/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_stapling on;
#ssl_stapling_verify on;
#ssl_trusted_certificate /etc/nginx/cert/trustchain.crt;
#resolver 8.8.8.8 8.8.4.4;
#add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Strict-Transport-Security "max-age=31536000" always;
# Rest of your regular config goes here:
# […]
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment