配置证书
/etc/nginx/conf.d/ssl.conf
server {listen 443;server_name guohe.group; # 改为绑定证书的域名ssl on;ssl_certificate 1_guohe.group_bundle.crt; # 改为自己申请得到的 crt 文件的名称ssl_certificate_key 2_guohe.group.key; # 改为自己申请得到的 key 文件的名称ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_ciphers on;location / {# root /usr/share/nginx/html; #站点目录# index index.html index.htm;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $http_host;proxy_set_header X-Forwarded-Proto $scheme;proxy_pass http://127.0.0.1:2368;}}
使用全站加密,http 自动跳转 https
Nginx 支持 rewrite(只要在编译的时候没有去掉 pcre)
在 http 的 server (网站的配置文件)里增加 rewrite ^(.*) https://$host$1 permanent;
这样就可以实现 80 进来的请求,重定向为 https 了。
