nginx配置https 强制使用https

免费证书申请地址:

https://freessl.cn/

申请步骤:

1.申请域名,

2.在云解析(阿里云域名解析  看自己申请域名的平台)配置TXT值  
3.验证域名

4.下载域名key 和 pem配置到nginx中

server {
listen 80;
server_name xxx.com;
rewrite ^ https:/$http_host$request_uri? permanent;
}

server {
listen 443 ssl;
server_name  xxx.com;

ssl_certificate cert/xxx.pem;
ssl_certificate_key cert/xxx.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;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http:// xxx.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
}
}

posted @ 2020-06-10 16:44  木有昵称  阅读(734)  评论(1编辑  收藏  举报