云码酷 发表于 2025-6-16 17:24:06

免费申请SSL证书并无限续期

1. SSL证书的作用
数据加密和传输安全‌:SSL证书通过TLS/SSL协议加密传输,确保数据在传输过程中不会被截获或篡改。这可以有效防止黑客通过钓鱼攻击和中间人攻击获取用户的敏感信息,如支付信息、登录凭证等‌
提升搜索引擎排名‌:部署了HTTPS的网站在搜索引擎中的排名会更高,因为HTTPS协议表明网站采用了加密连接,提升了用户的数据安全感和信任度。这有助于降低用户的跳出率,延长用户在网页上的停留时间‌
增强用户体验‌:浏览器地址栏的“绿色小锁”和“https://”前缀可以让用户感到安全,减少用户因不安全警告而跳出网站的情况。此外,SSL证书可以屏蔽一些无良广告的干扰,减少客户流失
在开发微信小程序时,如果是自己部署后端API,必须使用带有https的域名
2. 安装要求
一个已备案并配置解析的域名,如鹅云或阿里云申请
一台公网服务器(linux),如鹅云或阿里云
nginx web服务器
3. 安装步骤
3.1 系统依赖更新
CenterOS系统:

yum update && yum install curl -y && yum install cron -y && yum install socat -y
Debian/Ubuntu系统:

apt-get update && apt-get install curl -y && apt-get install cron -y && apt-get install socat -y
3.2 安装acme.sh脚本
3.2.1 使用curl安装
curl https://get.acme.sh | sh -s email=my@example.com

3.2.2 使用GIT安装
yum install git

git clone https://github.com/acmesh-official/acme.sh

cd acme.sh ./acme.sh --install -m 1111@qq.com

source ~/.bashrc 重新加载bash

3.3 注册并配置域名密钥(鹅云)
wx扫码就可以登录DNSPod,否则需要注册绑定。登录之后,点击头像下的 「API密钥」:

配置域名密钥到服务器环境变量
export DP_Id='你的ID'
export DP_Key='你的Token'
3.4 申请证书
使用下面命令,假设域名是:abc.com
acme.sh--register-account-m 邮箱@qq.com --server zerossl//注册账号
acme.sh --issue --dns dns_dp -d kikakika.com -d *.abc.com//颁发证书
默认生成的证书都放在安装目录 ~/.acme.sh/ 下,但是请不要直接使用。而是使用 --installcert 命令安装证书,这里默认你已装好nginx
acme.sh--installcert-daaa.cn   \
      --key-file   /etc/nginx/ssl/aaa.cn.key \
      --fullchain-file /etc/nginx/ssl/fullchain.cer \
      --reloadcmd"systemctl reload nginx.service
上面安装完,acme会自动续期,可以查看定时任务:crontab -l
3.5 配置nginx
这里支持通配符证书,自己去域名管理创建子域名

ssl_certificate_key   /etc/nginx/ssl/abc.com.key;

server {
    listen 443 ssl;
    server_name   api.abc.com;
    location / {
      client_max_body_size10M;   
      proxy_pass         http://localhost:5268;
      proxy_http_version 1.1;
      proxy_set_header   Upgrade $http_upgrade;
      proxy_set_header   Connection $connection_upgrade;
      proxy_set_header   Host $host;
      proxy_cache_bypass $http_upgrade;
      proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

server {
    listen      80;
    server_name   api.abc.c;
    return 301 https://$host$request_uri;
}

lydr 发表于 2025-6-16 17:24:55

为保住菊花,这个一定得回复!

tqg6j 发表于 2025-6-16 17:57:48

闲逛中发现此帖闪光点,那就助力一把,顶啦。

4cg_r 发表于 2025-6-16 18:29:09

学习下

szn 发表于 2025-6-16 18:40:09

好帖必须得顶起

tza 发表于 2025-6-16 19:14:08

嘘,低调。

4ddc 发表于 2025-6-16 19:35:42

垃圾内容,路过为证。

oodzh 发表于 2025-6-16 19:46:04

广告位,,坐下看看

rzz 发表于 2025-6-16 20:17:59

报告!别开枪,我就是路过来看看的。。。

8qag 发表于 2025-6-16 20:28:19

楼主呀,,,您太有才了。。。
页: [1] 2
查看完整版本: 免费申请SSL证书并无限续期