如何部署SSL免费证书

 本文讲述如何通过阿里云申请免费ssl证书,每人可申请20次,每个ssl时限1年

【阿里云免费证书申请指南】
https://help.aliyun.com/document_detail/98728.htm?spm=a2c4g.11186623.0.0.496a3103bZCxey#concept-n45-21x-yfb


1. 上阿里云申请免费SSL证书
https://yundun.console.aliyun.com/?spm=5176.12818093.ProductAndService--ali--widget-home-product-recent.dre0.44b216d0ioUR7g&p=cas#/certExtend/free

填写申请
domain.com

域名验证方式
  文件验证
秘钥算法
  RSA
CSR生成方式
  系统生成
验证信息
.well-known/pki-validation/filename.txt


2. 等待审核
已签发之后,删除filename.txt校验文件
下载证书,选择服务器nginx
上传到服务器/data/server/nginx/conf/cert/

3. 配置nginx

server {
listen 80;
server_name xxx;
新增强制跳转
rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS
...

}
新增443 server
server {
listen 443 ssl;
server_name domain.com; #证书绑定的域名。
...

ssl_certificate /pathto/domain.com.pem; #已上传的证书文件的名称。
ssl_certificate_key /pathto/domain.com.key; #已上传的证书密钥文件的名称。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的类型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS协议的类型。
ssl_prefer_server_ciphers on;

...

}

 

4.在cloudflare托管平台中需注意
【cloudflare配置】
SSL/TLS中选择完全模式(端到端加密,使用服务器上的自签名证书)

 

5.在wordpress中需注意
在functions.php中新增代码:

function hook_scripts_to_wp_head() {
?>
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<?php
}
add_action('wp_head', 'hook_scripts_to_wp_head');

 

【报错解决】
1. File not found.
检查cloudflare ssl/tls模式
2. Welcome to nginx!
检查cloudflare ssl/tls模式

posted @ 2022-10-11 14:27  风不会停息7  阅读(7)  评论(0)    收藏  举报