最近发现DNSPods可以免费申请SSL证书,就顺便把自己的网站从http升级到了https访问,下面记录本次升级过程。

      申请证书

      证书是与域名绑定到一起,所以在申请证书前需要申请一个域名,申请完成之后在DNSPod中为指定域名点击申请证书,步骤非常简单,申请完成之后点击下载证书即可。

      nginx配置

      由于我的wordpress是服务器厂商自带的应用程序镜像,参考帮助文章,替换文件即可:

      How to install a commercial SSL certificate
      1. Obtain a certificate from a certificate authority for your domain.
      2.Replace the server.crt and server.key files in /etc/nginx/ssl/ with the commercial certificate. Refer to your certificate vendor's documentation for details.
      3.Reboot the server.

      最后一句重启真是简单又直接。

      修复Bug

      重启完系统后,已经可以通过https访问网站了,但是部分资源是写死用http访问的,因此部分页面可能会出现如下错误提示:

      Mixed Content: The page at ‘xxx’ was loaded over HTTPS, but requested an insecure resource ‘xxx’. This request has been blocked; the content must be served over HTTPS.

      解决这个问题,只需要在head中添加如下标签,将不安全的请求提升为安全的请求:

      <meta http-equiv='Content-Security-Policy' content='upgrade-insecure-requests'>

      在wordpress中只需要修改对应主题文件和wp-admin的header文件,在其中加入上面的标签即可。


      1 条评论

      נערות ליווי במרכז · 2022年4月20日 下午8:57

      Next time I read a blog, Hopefully it does not disappoint me as much as this one. After all, Yes, it was my choice to read through, nonetheless I truly thought youd have something helpful to talk about. All I hear is a bunch of crying about something that you can fix if you were not too busy seeking attention.

      发表评论

      您的电子邮箱地址不会被公开。 必填项已用*标注