https进行配置以及http跳转到https配置

https配置:


 

nginx配置

server {
listen 443;
server_name localhost;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/a.pem;
ssl_certificate_key cert/a.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;
location / {
root html;
index index.html index.htm;

 


 

http 强制转换https


    在配置文件中加入下面代码

server {

    ...

 

    if ($server_port = 80){ 

return 301 https://$server_name$request_uri;} 

 

if ($scheme = http){ 

return 301 https://$server_name$request_uri;} 

    ....

}

 

posted @ 2019-04-12 16:47  zhouyuqiang  阅读(1637)  评论(0编辑  收藏  举报