子域的通配符证书?

Wild Card certificate for Subdomains?

我处于必须使用 HTTPS 的情况。 (chrome 决定停止 HTTP 中的 getUserMedia )。

问题是,是否可以分配通配符域? 这是我的几个网站

1 test.nfgold.me
1 slave.nfgold.me
3 *.nfgold.me

目前没有使用HTTPS,我在我的nginx中有以下配置:

server {
    server_name *.nfgold.me;-
    charset utf-8;

    .....
}

这绝对有效。

我在我的几个项目中使用了 letsencrypt,但它目前似乎没有使用通配符?

我尝试了以下配置,但它不起作用:

server {
        server_name .nfgold.me;
        rewrite ^ https://*.nfgold.me$request_uri? permanent;
    }

server {
        server_name .nfgold.me;
        rewrite ^ https://*.nfgold.me$request_uri? permanent;
    }

server {
    listen 443;
    server_name *.nfgold.me;-
    charset utf-8;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/nfgold.me/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nfgold.me/privkey.pem;
    ....
    }

有替代方案吗?任何建议。

Is there an alternative for this ? Any Suggestion.

虽然 Let's Encrypt 不会为您提供通配符证书1,但您可以拥有包含多个子域的证书。来自 their FAQ:

Can I get a certificate for multiple domain names (SAN certificates or UCC certificates)?

Yes, the same certificate can contain several different names using the Subject Alternative Name (SAN) mechanism.

当然,您可以在其他地方购买通配符证书,即许多 CA 都提供这些证书。


1 从 01/2018 开始,您还可以从 Let's Encrypt

获取通配符证书

尝试使用通配符子域进行加密,使用 DNS 验证。

sudo certbot -d *.example.com --manual --preferred-challenges dns certonly

在此之后,您必须手动将证书路由添加到您的服务器块。

我试图创建一个详细的 post 解释如何创建通配符认证。我希望这个 post 可以帮助:

sudo certbot certonly \
  --cert-name mydomain.com \
  --dns-digitalocean \
  --dns-digitalocean-credentials ~/.secrets/do_token.ini \
  --server https://acme-v02.api.letsencrypt.org/directory \
  -d "*.mydomain.com" \
  -d mydomain.com \
  -i nginx

可在此处找到详细信息: https://huogerac.hashnode.dev/add-wildcard-https-on-digital-ocean-using-certbot-ubuntu-20-nginx-cko511nxv04in83s15uxxbeea