Nginx 1.15后开启https 略有不同,这里借用宝塔默认的配置记录一下
server
{
listen 80;
listen 443 ssl http2; # 注意,新的Nginx都是在这里监听,不用再 ssl on
server_name www.xiaole88.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/www.xiaole88.com;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#HTTP_TO_HTTPS_START
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
#HTTP_TO_HTTPS_END
ssl_certificate /www/server/www.xiaole88.com/fullchain.pem;
ssl_certificate_key /www/server/www.xiaole88.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m; #最好开启这个,能加速建立链接速度
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000"; #告诉浏览器后续都应该用https来请求
.......
}
共 0 条评论