网站ssl配置,http改https步骤
2022-08-11 加入收藏
网站做好后默认是http协议访问的,有的浏览器会提示不安全,所以需要将http协议改成https,那么配置方法如下:
1,到阿里云申请免费证书,然后下载证书文件
2,将网站上所有的http全部改成https
例如:
<script src="http://foo.com/jquery.js"></script> <!-- 改法一 --> <script src="https://foo.com/jquery.js"></script> <!-- 改法二 --> <script src="//foo.com/jquery.js"></script>
3,修改Nginx配置文件(设置80重定向到443,配置端口443,指定证书路径)
server { listen 80; return 301 https://$server_name$request_uri; } server { listen 443; server_name 域名; root /usr/share/nginx/html; index index.html index.php index.htm; ssl_certificate "路径.crt"; ssl_certificate_key "路径.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; }