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

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


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

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

https的免费部署方案(阿里云主机)_第1张图片


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

https的免费部署方案(阿里云主机)_第2张图片


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

https的免费部署方案(阿里云主机)_第3张图片


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

https的免费部署方案(阿里云主机)_第4张图片


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 :

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

7.最后. 升级 https成功!

https的免费部署方案(阿里云主机)_第5张图片


你可能感兴趣的:(linux)