本地开发环境,使用chrome浏览器测试时,如果不配置https,比较麻烦,所以还是在本地也配置个用起来顺心些。
macos:
1 2
| brew install mkcertmkcert -install mkcert xxx.com
|
生成2个文件: ~/xxx.com-key.pem, ~/xxx.com.pem
修改此站点nginx配置:
1 2 3 4 5 6 7 8 9 10 11 12
| server { listen 443 ssl; ssl_certificate /etc/nginx/xxx.com.pem; ssl_certificate_key /etc/nginx/xxx.com-key.pem; server_name xxx.com; …… } server { listen 80; server_name xxx.com; return 301 https://$host$request_uri; }
|
浏览器测试效果,完毕