let’s Encrypt 证书之安装故障 Could not bind to IPv4 or IPv6.

背景:nginx 作为反代理服务器,配置了多域名,有三个站点开了https,certbot  renew 只能更新其中的两个域名的证书,有一个域名的证书提示‘Failed to renew certificate xxxxxx.com.cn with error: Problem binding to port 80: Could not bind to IPv4 or IPv6.’

 

网上查资料都说要停nginx,因为nginx占用了80端口,导致certbot不能使用默认的80端口;这个说法明显不靠谱,因为同个服务器有两个域名是可以正常更新的,另外每次更新证书都关nginx明显不合理。

经过对比发现有问题的域名和正常域名的配置有不一致:

1
/etc/letsencrypt/renewal/xxxxxx.conf  #配置文件

.

1
#有问题的配配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# renew_before_expiry = 30 days
version = 1.11.0
archive_dir = /etc/letsencrypt/archive/xxxxxx.com.cn
cert = /etc/letsencrypt/live/xxxxxx.com.cn/cert.pem
privkey = /etc/letsencrypt/live/xxxxxx.com.cn/privkey.pem
chain = /etc/letsencrypt/live/xxxxxx.com.cn/chain.pem
fullchain = /etc/letsencrypt/live/xxxxxx.com.cn/fullchain.pem
 
# Options used in the renewal process
[renewalparams]
account = xxxxxx
manual_public_ip_logging_ok = None
server = https://acme-v02.api.letsencrypt.org/directory
authenticator = standalone
webroot_path = /var/www/xxxxxx.com.cn,
[[webroot_map]]

 

1
#正常的配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# renew_before_expiry = 30 days
version = 1.11.0
archive_dir = /etc/letsencrypt/archive/xxxxxx.com.cn
cert = /etc/letsencrypt/live/xxxxxx.com.cn/cert.pem
privkey = /etc/letsencrypt/live/xxxxxx.com.cn/privkey.pem
chain = /etc/letsencrypt/live/xxxxxx.com.cn/chain.pem
fullchain = /etc/letsencrypt/live/xxxxxx.com.cn/fullchain.pem
 
# Options used in the renewal process
[renewalparams]
account = xxxxxx
manual_public_ip_logging_ok = None
server = https://acme-v02.api.letsencrypt.org/directory
authenticator = webroot   #验证方式有 apache、nginx、standalone、webroot、manual
webroot_path = /var/www/xxxxxx.com.cn,
[[webroot_map]]
uwms.timeexpress.com.cn = /var/www/uwms.timeexpress.com.cn  #映射验证id存放的位置

 

问题就出在认证域名所有权这里

certbot分发证书工作过程:

1、certbot启动,向服务器发出证书请求

2、服务器根据certbot客户端配置的验证方式做出响应。认证方式有两种:a、文件;b、DNS

3、文件认证:

a、服务端发回一个id给客户端

b、客户端启动web服务或者使用现有的web服务

c、把id挂到web服务上,服务端通过域名访问这个web服务读取id

d、如果读到的id和自己发的id一致验证成功签发证书

4、dns认证

a、服务端返回域名txt记录

b、在自己域名dns解析里添加txt记录后验证,添加后enter继续

c、服务端访问txt记录,解析成功签发证书

 

 

 

dns认证方式:manuanl

文件认证方式:apache,nginx,standalone,webroot

 

standalone  certbot自己启动一个web站点(默认端口80)给验证服务器访问,当我们服务器上有占用80口的时候就会报开头的错误。

 

使用webroot 验证时使用现有的web服务,不需要单独再启动。需要在nginx host配置下面增加下面代码,同时创建/var/www/xxxxxx 目录。:

1
2
3
location /.well-known {
           alias /var/www/xxxxxx/.well-known;
   }

  

 平时安装完certbot后用下面命令获取证书:

./certbot-auto certonly --webroot --agree-tos -v -t --email info.public@xxxxxx.com.cn -w /var/www/oa.timeexpress.com.cn  -d oa.timeexpress.com.cn

--webroot  指定了认证方式

--email  邮箱

-w  验证文件存放路径

-d  域名

 
 
posted @   Bein28  阅读(237)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示