Nginx 配置https 自动续期

本文详细介绍如何使用acme.sh脚本自动化部署SSL证书,包括在nginx中启用http_v2_module,阿里云DNS验证,以及nginx配置更新和重启流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#安装 acme.sh
curl https://get.acme.sh | sh

#确保 nginx安装了 http_v2_module
nginx源码目录下
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module

make && make install
pkall nginx
nginx

#阿里云的授权配制
# 替换成从阿里云 域名账号 后台获取的密钥(https://usercenter.console.aliyun.com/)
export Ali_Key="key"
export Ali_Secret="secret"

#开始生成
acme.sh --issue --dns dns_ali -d www.baidu.com

这里可以使用通配符的域名例如
acme.sh --issue --dns dns_ali -d *.baidu.com

#nginx配置
server {
    server_name xx.domain.com;
    listen 443 http2 ssl;
    ssl_certificate_key /path/.acme.sh/domain/domain.key;
    ssl_trusted_certificate  /path/.acme.sh/domain/ca.cer;
    ssl_certificate /path/.acme.sh/domain/fullchain.cer;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:10086;
    }
}
#停止
nginx -s stop
#重启
nginx

更新
重新执行生成命令 并且nginx -s reload

参考https://my.oschina.net/kimver/blog/1634575?p=3&temp=1521449027784

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值