使用certbot续期ssl证书renew时遇到问题

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://blog.youkuaiyun.com/qq_19868745/article/details/72677709

遇到的问题如下:IMPORTANT NOTES:

 - The following errors were reported by the server:


   Domain: www.miling.online
   Type:   unauthorized
   Detail: Invalid response from
   http://www.miling.online/.well-known/acme-challenge/8IPPiMABwsHSwqSSTfZ5XMv7wD9sqXdO1pzOwFebdzg
   [2001:470:35:bf9::2]: 404


   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# certbot-auto renew --force-renew
-bash: certbot-auto: command not found
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# 
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# 1
-bash: 1: command not found
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# certbot renew --quiet
Attempting to renew cert from /etc/letsencrypt/renewal/www.miling.online.conf produced an unexpected error: Failed authorization procedure. www.miling.online (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.miling.online/.well-known/acme-challenge/o30LM-8eAdn4IB8vX96Aa1Xgs6Mwc-5QjJNQ8mjl_Ns [2001:470:35:bf9::2]: 404. Skipping.


All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/www.miling.online/fullchain.pem (failure)

1 renew failure(s), 0 parse failure(s)

最后查看了certbot的帮助


依次运行:

# service nginx stop

# certbot --force-renewal

# certbot certonly

# certbot renew --dry-run

# cerbot nginx start



需要注意的是service nginx stop/start,否则会出现问题


<think>我们使用certbot为Debian系统上的Nginx配置SSL证书,以实现HTTPS访问。以下是基本步骤: 1. 安装CertbotNginx插件: Certbot有一个专门用于Nginx的插件,可以自动配置SSL证书并修改Nginx配置。 2. 获取SSL证书并自动配置Nginx: 运行Certbot命令,它会引导你完成证书申请过程,并自动修改Nginx配置文件以使用SSL。 3. 验证Certbot自动续期Certbot申请的证书有效期为90天,但Certbot会自动设置定任务来续期证书,通常不需要手动干预。 具体步骤: ### 步骤1:安装CertbotNginx插件 在Debian系统上,可以使用以下命令安装: ```bash sudo apt update sudo apt install certbot python3-certbot-nginx ``` ### 步骤2:获取SSL证书并自动配置Nginx 确保你的Nginx配置中已经为你的域名设置好了server块(即虚拟主机配置)。然后运行: ```bash sudo certbot --nginx ``` Certbot会提示你输入邮箱(用于紧急通知和安全通知),同意服务条款,以及选择要为哪个域名启用HTTPS(它会读取Nginx配置中的域名列表)。之后,它会自动获取证书并修改Nginx配置,将HTTP重定向到HTTPS。 ### 步骤3:验证自动续期 Certbot安装会自动创建一个定任务,用于自动续期即将过期的证书。你可以通过以下命令测试续期是否正常工作: ```bash sudo certbot renew --dry-run ``` 如果输出没有错误,则表示自动续期配置成功。 ### 额外说明 - 防火墙:确保防火墙允许HTTPS(端口443)的流量。 - Nginx配置:Certbot会自动修改你的Nginx配置文件(通常位于`/etc/nginx/sites-available/`下),添加SSL相关的配置,并创建重定向。 ### 验证 完成上述步骤后,你可以通过浏览器访问`https://yourdomain.com`来验证证书是否生效。 §§相关问题§§ 1. 如果我的域名没有在Nginx配置中预先设置,Certbot还能自动配置SSL吗? 2. 如何配置Certbot以自动续期SSL证书,而不需要手动干预? 3. 如果我想为多个域名或子域名申请同一个SSL证书,应该如何使用Certbot? 4. 在配置SSL证书后,如何检查我的Nginx配置是否正确且没有语法错误? 5. 如果遇到Certbot申请证书失败,可能的原因有哪些以及如何排查?</think>### 在Debian系统使用CertbotNginx配置SSL证书 #### 操作步骤: 1. **安装CertbotNginx插件** ```bash sudo apt update sudo apt install certbot python3-certbot-nginx ``` 2. **确保Nginx配置域名** 在`/etc/nginx/sites-available/`中配置域名,例如: ```nginx server { listen 80; server_name example.com www.example.com; root /var/www/html; } ``` 测试配置后重启: ```bash sudo nginx -t && sudo systemctl reload nginx ``` 3. **获取SSL证书** ```bash sudo certbot --nginx -d example.com -d www.example.com ``` - 按提示输入邮箱(用于安全通知) - 同意服务条款 - 选择是否开启HTTPS强制跳转(推荐选2) 4. **验证自动续期** ```bash sudo certbot renew --dry-run # 测试自动续期功能 ``` Certbot会自动创建定任务(在`/etc/cron.d/certbot`) #### 关键说明: - 证书位置:`/etc/letsencrypt/live/your_domain/` - 自动修改的Nginx配置:在原有`server`块中添加了: ```nginx listen 443 ssl; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ``` #### 验证HTTPS: 访问 `https://your-domain.com`,浏览器地址栏应显示🔒锁标志。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值