https的免费部署方案(阿里云主机)

https 已经是现代网站的标配,chrome 已经自动默认http为不安全网站,搜索引擎也优先收录 https 站点,还有什么理由不升级呢?


1.首先我们需要CA证书,如果你的服务器是阿里云的,点开下面的连接来获取。

https://yundun.console.aliyun.com/?p=cas#/cas/home

这里写图片描述


2.这是购买的截图,你可以选择自己想要的类型,我选择的是免费的SSL 。

这里写图片描述


3.购买付费之后,填一些资料就可以了。一般审核10分钟就可以了,成功之后,点击发布的证书,下载,会提示你选择对应的 网络服务 的证书,这里我们以 nginx 为例。

这里写图片描述


4.下载解压之后,有一个 xxx.pem 和一个 xxx.key 。将这两个文件传到你的web 服务器上,路径不重要,在 nginx 配置中引入路径就可以了。

这里写图片描述


5. nginx 的配置,这里我的 web 域名是 www.leon0204.com

server {
  listen       443 ssl http2;
  server_name  www.leon0204.com;
  ssl          on;
  root /网站根目录;
  index index.html index.htm index.php;
  location / {
            try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
          try_files $uri $uri/ =404;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME
          $document_root$fastcgi_script_name;
          include fastcgi_params;
   }

ssl_certificate   /这里填你刚刚下载上传的文件/xxx.pem;
ssl_certificate_key  /这里填你刚刚下载上传的文件/xxxxkey;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
}

##http 跳转 https  
server{  
  listen        80;
  server_name   www.leon0204.com;
  return 301    https://$host$request_uri;

}

6.配置中遇到的一些其他问题

Question :https网站中的http资源 block 的问题

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

Answer :

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests”>   // 用于转换http ->https

7.最后. 升级 https成功!

这里写图片描述


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值