域名配置https Ngnix配置详细教程
获取到Ngnix相关ssl证书,如下图,(可百度免费获取方法) 将上面两个文件放到Ngnix安装目录的conf文件下 ,然后配置nginx.conf文件,添加如下内容:
server
{
charset utf8;
listen 443 ssl;
root /opt/local;
server_name www.aromadoctrine.com;
ssl_certificate 7525390_aromadoctrine.com.pem;
ssl_certificate_key 7525390_aromadoctrine.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
}
server
{
listen 80;
server_name aromadoctrine.com;
rewrite ^/(.*) https://www.aromadoctrine.com permanent;
}
成功之后重启Ngnix即可。 注意避坑:nginx 1.15 及以后的版本(跟我一样配置即可) 是listen 443 ssl 而不是listen 443,然后要删掉ssl on ! 最后如果是服务器的话记得打开443端口哦!
|