Wildcard subdomain NGINX and ACME

You’re trying to issue a certificate for “~^(?.+)\.test\.jayhenks\.com$” domain, which is obviously is not a valid domain. For wildcard domain you need to use security.acme.certs option instead and point nginx to it using useACMEHost option.

Something like this:

  security.acme.certs."test.jayhenks.com" = {
    domain = "*.test.jayhenks.com";
    dnsProvider = "cloudflare";
    credentialsFile = "/path/to/credentials.env"
    group = config.services.nginx.group;
  };

  services.nginx = {
    enable = true;
    virtualHosts = {
      "~^(?<subdomain>.+)\\.test\\.jayhenks\\.com$" = {
        useACMEHost = "test.jayhenks.com";
        <....>
      };
    };
  };
3 Likes