首页 > 解决方案 > 如何在端口 1337 上刷新代理服务器的 SSL 证书?

问题描述

我有一个域,出于安全原因,我将其简称为“example.org”,它运行在我试图让 SSL 访问工作的 Amazon EC2 上。我正在使用letsencrypt 和certbot 来颁发我的证书。在我尝试更新 SSL 证书之前,前 90 天一切正常。我能够成功刷新我的域名的证书,但由于某种原因,我似乎有一个单独的证书用于我在端口 1337 上使用的代理服务器,显示为过期。

当我尝试在我的网站上使用应用程序时,我在浏览器的 JavaScript 控制台上看到以下错误:

example.org:1337 uses an invalid security certificate.

The certificate expired on Tuesday, October 9, 2018, 7:50 PM. The current time is Friday, October 19, 2018, 3:43 PM.

Error code: <a id="errorCode" title="SEC_ERROR_EXPIRED_CERTIFICATE">SEC_ERROR_EXPIRED_CERTIFICATE</a>
 (unknown) 

我的客户端应用程序是直接与“ https://example.org:1337 ”通信的 Angular 6 SPA。

使用SSL 检查器,我可以看到我的“example.org”显示域级别证书将在 47 天后过期。但是,当我查看“example.org:1337”时,它显示证书已于 13 天前过期。我的理解是每个域只需要一个 SSL 证书,我不必单独验证每个端口。我最初并没有为端口 1337 请求证书,但我确实在“/etc/apache2/sites-available/000-default-le-ssl.conf”中为其指定了 proxyPass

# allow us to call a node server without the user having to specify the port number 
# directly e.g. call the proxy server like it's a standard http route.
ProxyRequests off

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

<Location /servers/meta-data-proxy>
    ProxyPass https://localhost:1337
    ProxyPassReverse https://localhost:1337
</Location>

当我对我使用的另一个没有代理的端口进行 SSL 检查时,它会显示“未找到 ssl 证书”,这是我所期望的。

certbot 显示以下证书:

> sudo certbot certifictes
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: example.org
    Domains: example.org www.example.org
    Expiry Date: 2018-12-09 11:08:32+00:00 (VALID: 47 days)
    Certificate Path: /etc/letsencrypt/live/example.org/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/example.org/privkey.pem

我该如何:
a)刷新或同步端口 1337 上的证书以与域名上的证书同步?

b)以某种方式删除我机器上端口 1337 上的过期证书。根据 certbot,我没有看到它在任何地方列出。我希望通过删除它,它会以某种方式重新动态设置。

我什至不确定我是否需要一个“ProxyPass”。这可能是我最初只是为了让事情正常工作而做的事情,但并不是真正需要的。

Ubuntu 18.04 Apache2 2.4.29

标签: sslssl-certificateapache2

解决方案


对不起大家:这个属于没关系/用户错误的类别。

结果我确实/etc/letsencrypt/live/example.org/fullchain.pem将and复制/etc/letsencrypt/live/example.org/privkey.pem到了代理服务器的子目录中。侦听端口 1337 的代理服务器然后加载这些文件。一旦我使用主 https 服务器使用的更新版本刷新它们,一切都会再次运行。所以实际上,我确实有两个版本的密钥,你只能通过查看代码来弄清楚这一点。

我真的不必记住要这样做,我会说这反映了我的应用程序的糟糕设计。让客户端直接引用端口号可能不是一个好主意。我真的应该让客户端通过一个端口(例如 SSL 的 443)引用服务器,然后让服务器决定重定向到任何内部服务器。我的应用程序最初只运行 http,我并没有真正考虑过安全问题。然后我在最后一秒添加了 https。由于对 SSL 不是很熟悉,所以我把它变成了一个比我不得不做的更难的问题,所以这就是我的辩护。啊。


推荐阅读