对具有分布式流量的多个 Apache 服务器使用 Lets Encrypt SSL

Jus*_*tin 2 centos haproxy apache-2.4 centos7 lets-encrypt

我在为在两个不同服务器上设置的几个网站设置 Let's Encrypt 时遇到一些问题,并通过 HAProxy 将流量分配给它们。

服务器上有许多 VHosts/域,所有这些都需要 SSL 证书。为了这篇文章,让我们说他们是:

  1. foo.some-site.com
  2. bar.some-site.com

这两个 A 记录都设置有两个 IP 地址。我可以通过 nwtools.com 或 nslookup 验证 A 记录foo.some-site.combar.some-site.com解析相同的两个 IP 地址。而且我知道 Let's Encrypt 要求 vhost 使用有效记录,以便它可以进行查找。

我计划在两台服务器上为所有虚拟主机运行 Lets Encrypt 设置,其中一台运行良好,但是当我转到第二台时,出现错误:

[root@server httpd]# /opt/letsencrypt/letsencrypt-auto --apache -d foo.some-site.com
Checking for new version...
Requesting root privileges to run letsencrypt...
   /root/.local/share/letsencrypt/bin/letsencrypt --apache -d foo.some-site.com
Failed authorization procedure. foo.some-site.com (tls-sni-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Failed to connect to host for DVSNI challenge

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: foo.some-site.com
   Type:   connection
   Detail: Failed to connect to host for DVSNI challenge

   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. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.
Run Code Online (Sandbox Code Playgroud)

这可能是因为它正在查找或试图卷曲foo.some-site.com,并且它可能被定向到另一台服务器?我不确定这有什么关系,因为两者都有相同的 VHost,除非 LetsEncrypt 实际上正在监听它自己建立的连接......

让我失望的是,它对其中一个网站很好用(比如bar.some-site.com),那么为什么它适用于一个站点,但对于另一个具有完全相同设置的站点却失败了?

如果有人知道在两个不同的服务器上为相同的虚拟主机设置 Lets Encrypt 的方法,我们将不胜感激!

EEA*_*EAA 5

这可能是因为它正在查找或试图卷曲 foo.some-site.com,并且它可能被定向到另一台服务器?

是的,绝对是。

作为域验证质询-响应过程的一部分,LE 需要连接回您运行 LE 客户端的服务器。无需详细说明,LE 客户端实际上会在您的网络服务器中临时提供某个文件,LE 服务器需要能够使用该文件来验证域所有权。

在所有后端服务器上运行此命令是不必要且麻烦的。运行一次,然后将密钥和证书链复制到其余的后端服务器。

让我失望的是,它对其中一个网站工作得很好(比如 bar.some-site.com),那么为什么它适用于一个站点,但对于另一个具有完全相同设置的站点却失败了?

因为你走运?:) 有可能您的负载均衡器偶然将 LE 请求定向到正确的位置一次,但第二次没有这样做。