首页 > 解决方案 > 多个子域的通配符 SSL 证书

问题描述

我有一个有多个客户端的系统。每个客户端都有自己的子域。

client1.example.com
client2.example.com
...

在服务器端,所有请求都被重定向到*.example.com. 然后我的业务逻辑读取子域(如client1)并相应地响应客户端。

所以基本上,我不会在服务器上配置每个子域。我只是将它添加到我的数据库中,我的代码会正确处理它。

我正在尝试将通配符 SSL 证书应用于所有这些子域。另外,我希望所有未来的客户都能自动获得https.

但我不知道如何配置它。我试过使用Let's Encrypt,但没有运气。实际域example.com获取https但不是客户端域。

任何有关配置的帮助都会非常有帮助。或者,可能是,这种设置是不可能的。我不知道。

请帮忙。

PSexample.com只是我指的一个虚拟域。

PPS 我在 Ubuntu 16.04 x64 上使用 apache2 网络服务器

标签: apacheubuntuhttpsssl-certificatewildcard-subdomain

解决方案


嗯,这是可能的。我现在有一个证书,*.example.com它适用于我所有的任意子域,即,

client1.example.com
client2.example.com
...

我按照以下步骤操作:

$ wget https://dl.eff.org/certbot-auto
$ chmod a+x ./certbot-auto

$ sudo ./certbot-auto certonly \
--server https://acme-v02.api.letsencrypt.org/directory \
--manual --preferred-challenges dns \
-d *.example.com

然后使用在创建的文件/etc/letsencrypt/live/example.com/,我从我的控制面板更新了值(我使用Vestacp

cat /etc/letsencrypt/live/example.com/cert.pem
^ Copy contents into “SSL Certificate” field.

cat /etc/letsencrypt/live/example.com/privkey.pem
^ Copy contents into “SSL Key” field.

cat /etc/letsencrypt/live/example.com/chain.pem
^ Copy contents into “SSL CA / Intermediate” field.

根据您的控制面板进行更改。

请按照本文了解详细步骤和说明。


推荐阅读