运维管理
MrDoc 速记插件
Docker 安装 mrdoc (开源版)
Docker-compose 安装 mrdoc
Linux之smartctl命令磁盘检测运维
Nginx配置服务并开机启动
yum安装与卸载软件常见命令「建议收藏」
yum 命令使用讲解
Nginx 映射本地静态文件
CentOS7.9 Docker部署Leanote
Nginx配置中的log_format
修改或者隐藏Nginx的版本号
centos编译安装方式升级snmpwalk命令到5.9.1从而支持SHA-512鉴权协议测试
PVE的local和local-lvm
markdown之群晖自建图床
Wireshark介绍及抓包分析
自定义数据推送到pushgateway及推送数据的注意事项
Prometheus监控实战系列十四:Pushgateway
使用 PushGateway 进行数据上报采集
RHEL6.0 yum安装报warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY错误-CSDN博客
烂泥:openvpn配置文件详解-烂泥行天下
RHEL系统以FTP服务器搭建yum源_rhel9 安装 ftp yum
详解用Navicat工具将Excel中的数据导入Mysql中 - Steven* - 博客园
Linux禁止ping以及开启ping的方法 - chenshoubiao - 博客园
MobaXterm设置无密码登录丨Pro Linux 基础篇
CentOS 安装 MySQL8,超详细!
percona-xtrabackup备份及恢复mysql操作
教你玩转MySQL8物理备份利器Xtrabackup
PVE浏览器中文设置
2024年PVE8最新安装使用指南|新手入门|安装|优化|Proxmox VE 8.1__什么值得买
sendmail发邮件注意事项
如何使用sqlite将db文件转成txt文件
一文让你学会,开源WAF雷池SafeLine
iptables按照指定国家屏蔽(GEOIP模块的安装与使用)
py3 容器适配conda24.3.0
CentOS7 配置 nginx 和 php 方案
Sakura Panel搭建教程-搭建属于自己的FRP管理面板
markdown之群晖自建图床
Debian12安装教程(保姆级)
CentOS 6.9密码修改
CentOS7如果忘记密码,密码重置详细步骤,保姆级教程。
利用CertBot实现免费SSL证书的自动签发与续签
证书3月一换很麻烦?一行命令让你解放双手
阿里云域名自动签发泛域名证书配置(最新篇)
Certimate证书自动续签
Auto-SSL
ubuntu忘记密码问题解决
Ubantu启动失败,提示“Started GNOME Display Manager”
kali网络配置(及配置ssh远程连接)
SSL证书--Let’s Encrypt和TrustAsia哪个好
PVE安装ikuai、openwrt以及lxc容器安装docker
Fail2Ban安全配置与应用
本文档使用 MrDoc 发布
-
+
首页
阿里云域名自动签发泛域名证书配置(最新篇)
> 本文适用于域名服务商是阿里云的用户参考,如果你想要的是单域名证书签发,可以参考 [在CentOS 7上配置Certbot以自动签发Nginx的HTTPS证书](https://www.sunyonghong.com/post/20241011514.html) 首先,您需要安装Certbot。由于CentOS 7默认的软件源可能不包含最新版本的Certbot,因此推荐使用Snap或直接从源代码安装。 ### [](#)1.1 安装Snapd ``` sudo yum install epel-release sudo yum install snapd sudo systemctl enable --now snapd.socket ``` ### [](#)1.2 通过Snap安装Certbot ``` sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot ``` > 如果这里报错 `error: too early for operation, device not yet seeded or device model not acknowledged` ,只需要执行下面的命令 ``` sudo ln -s /var/lib/snapd/snap /snap ``` 安装完成后再次执行命令通过Snap安装Certbot即可。 ## [](#)2\. 使用插件实现阿里云的域名自动解析 **说明:如果你之前已经已经使用snap方式安装了 `certbot-dns-aliyun`插件, 请使用下面的命令先移除** ``` sudo snap remove certbot-dns-aliyun ``` ### [](#)2.1 登录你的阿里云管理平台给账号赋权以及创建凭证 ### [](#)2.2 安装 aliyun cli 工具 ``` wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz tar xzvf aliyun-cli-linux-latest-amd64.tgz sudo cp aliyun /usr/local/bin rm aliyun ``` ### [](#)2.3 配置阿里云凭证信息 可以查看阿里云的官方文档 [配置凭证](https://help.aliyun.com/zh/cli/configure-credentials) ``` aliyun configure --profile AkProfile(可任意命名) ``` 运行后依次输入: ### [](#)2.4 安装 certbot-dns-aliyun 插件 > 该插件的开源地址是 [https://github.com/justjavac/certbot-dns-aliyun](https://github.com/justjavac/certbot-dns-aliyun) ``` # 若该地址无法下载,请下载 https://www.sunyonghong.com/zb_users/upload/2024/11/20241120104615173207077547696.zip文件,将zip解压后,将获得 alidns.sh 文件 wget https://cdn.jsdelivr.net/gh/justjavac/certbot-dns-aliyun@main/alidns.sh sudo cp alidns.sh /usr/local/bin sudo chmod +x /usr/local/bin/alidns.sh sudo ln -s /usr/local/bin/alidns.sh /usr/local/bin/alidns rm alidns.sh ``` ## [](#)3\. 测试申请证书 ``` sudo certbot certonly -d *.example.com --manual --preferred-challenges dns --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean" --dry-run ``` ## [](#)4\. 颁发证书 ### [](#)4.1 使用命令申请颁发证书 ``` sudo certbot certonly -d *.example.com --manual --preferred-challenges dns --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean" ``` - `-d`: 需要颁发的域名,支持泛域名,多个域名使用英文逗号分割 后续按提示输入邮箱和同意协议即可完成颁发 ### [](#)4.2 查看已颁发的证书 ``` sudo certbot certificates ``` ## [](#)5\. 生成nginx配置需要用的文件 因为在上方生成时,泛域名容易干扰原有的nginx配置文件,故而在生成时,不指定nginx插件 ### [](#)5.1 生成 `options-ssl-nginx.conf` 文件 该文件是 `ssl` 证书的参数配置文件,建议在 `/etc/letsencrypt/` 目录下创建 名为 `options-ssl-nginx.conf` 的文件,并加入以下内容 ``` # This file contains important security parameters. If you modify this file # manually, Certbot will be unable to automatically provide future security # updates. Instead, Certbot will print and log an error message with a path to # the up-to-date file that you will need to refer to when manually updating # this file. Contents are based on https://ssl-config.mozilla.org ssl_session_cache shared:le_nginx_SSL:10m; ssl_session_timeout 1440m; ssl_session_tickets off; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers off; ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"; ``` ### [](#)5.2 生成 `Diffie-Hellman` 参数文件 (可忽略) 在配置nginx时,有可能需要配置 `ssl_dhparam`, `ssl_dhparam` 的值是 `Diffie-Hellman` 参数文件地址,它在 SSL/TLS 握手过程中使用 `Diffie-Hellman` 密钥交换算法时起到关键作用。`Diffie-Hellman` 算法允许服务器和客户端在不直接传输密钥的情况下,共同生成一个共享的秘密密钥,这个密钥随后可以用于加密和解密通信。 执行以下命令生成 ``` openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048 ``` ## [](#)6\. 配置nginx 在你的nginx配置文件中,修改 `server` 配置下的监听端口、引入证书配置即可,如下 ``` listen 443 ssl; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;# 这行可以不配置 ``` 修改完成后可使用 `nginx -t` 测试,无误后重启即可生效 ## [](#)7\. 续签证书 ### [](#)7.1 检查Certbot的续签配置 ``` sudo certbot renew --manual --preferred-challenges dns --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean" --dry-run ``` ### [](#)7.2 手动续签 ``` sudo certbot renew --manual --preferred-challenges dns --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean" ``` ### [](#)7.3 使用计划任务自动续签 如每天的凌晨2点运行,自动续签证书 ``` # 平滑重启(建议) sudo tee /etc/cron.d/certbot <<-'EOF' 0 2 * * * root certbot renew --manual --preferred-challenges dns --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean" --deploy-hook "nginx -s reload" EOF ``` ``` # 强制重启 sudo tee /etc/cron.d/certbot <<-'EOF' 0 2 * * * root certbot renew --manual --preferred-challenges dns --manual-auth-hook "alidns" --manual-cleanup-hook "alidns clean" --deploy-hook "systemctl restart nginx" EOF ```
adouk
2025年6月19日 12:07
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码