1、先去申请ssl证书,这里就不多说了
2、nginx配置https
修改nginx配置文件,开启https
server { listen 80; server_name 127.0.0.1; #将请求转成https #早期写法 rewrite ^(.*)$ https://$host$1; #最新写法 return 301 https://$server_name$request_uri; }
server { listen 443 ssl; server_name 127.0.0.1; #填写证书文件名称 ssl_certificate /usr/local/nginx/cert/server.pem; #填写证书私钥文件名称 ssl_certificate_key /usr/local/nginx/cert/server.key; location / { root html; index index.html index.htm; }