问题
我有两个EC2
实例正在运行。当前有一个EC2
实例托管我的网站https://thechrisbolton.com,您可以看到它具有有效的letsencrypt
证书。我想在第二个EC2
实例上创建一个证书,将在该实例上部署我的应用程序。将我的应用程序部署到第二个EC2实例后,我将销毁第一个实例。但是,我无法在第二个EC2实例上创建证书。
错误
- The following errors were reported by the server:
Domain: thechrisbolton.com
Type: unauthorized
Detail: Invalid response from
https://thechrisbolton.com/.well-known/acme-challenge/kITr3I__o6eb_WH2cguR200gWnt998DN1s8xamtPIbM
[3.234.11.212]: "<html>\r\n<head><title>404 Not
Found</title></head>\r\n<body>\r\n<center><h1>404 Not
Found</h1></center>\r\n<hr><center>nginx/1.18.0</ce"
Domain: www.thechrisbolton.com
Type: unauthorized
Detail: Invalid response from
https://www.thechrisbolton.com/.well-known/acme-challenge/DhzxfraTsUeN3a7bXQhfzS36CTHRzlBUWVAHceD
ETB8
[3.234.11.212]: "<html>\r\n<head><title>404 Not
Found</title></head>\r\n<body>\r\n<center><h1>404 Not
Found</h1></center>\r\n<hr><center>nginx/1.18.0</ce"
我尝试过的事情
$ certbot certonly --standalone -d thechrisbolton.com -d www.thechrisbolton.
com
我已通读certbot documentation,试图找到一种方法来创建现有证书。看起来唯一可行的是--duplicate
标志。但这说明Most users will not need to issue this command in normal circumstances.
,所以我觉得如果我使用它会做错事情。
答案 0 :(得分:1)
您无法在第二个EC2实例上创建证书的原因。是因为域https://thechrisbolton.com/
没有指向第二个EC2实例。
工作方式
(仅为了说明,我简化了过程。)
certbot的工作方式是,它向“ Let's Encrypt”发送一个请求,以颁发给定域的证书(在本例中为https://thechrisbolton.com/
)。响应该请求,“ Let's Encrypt”(又名LE)为certbot提供了一个文件(也就是质询),该文件需要放置在可通过此URL http://<requested-domain>/.well-known/acme-challenge/
通过Internet访问的位置。 Certbot正是这样做的,并将文件放置在运行certbot --certonly
命令时给它的位置(在这种情况下,您使用了--standalone
选项,certbot在端口80上旋转了它自己的服务器并将文件放在位置/.well-known/acme-challenge/
上),然后再次调用“让我们加密”,说文件已准备好,请给我证书。 LE然后点击该URL,以验证该文件在给定位置是否可用。如果找到文件,则仅颁发证书。所有这些都是为了确保要求证书的人拥有他要证书的域。
解决方案是什么?
如果您使用的是静态IP,则只需将静态IP指向新的EC2实例,然后将证书移到新计算机上即可。
如果您无法执行此操作,请更新DNS条目以指向新EC2实例的公用IP,然后运行相同的certbot
命令。您现在正在运行。