Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell Caddy which sub domain to use

I am trying to use Caddy for the first time. I want to be able to serve several subdomains. Caddy requests SSL certificates from Let's Encrypt. I have managed to get this to work ok with only one domain name in the caddyfile.

However, suppose I have

www.example.com, test.example.com {
    ...  lots of settings
}

I am relying on the Let's Connect server calling back into one of those subdomains (i.e. not using DNS TXT records). But this raises questions:

  • Which one does Caddy use when it requests a certificate?
  • Is there a way to specify which one I want it to use?

(In the example above there are just two subdomain, but actually I'd like to know how to get it to work with more than two.)

-- EDIT: When I try this on test.example.com, I get an error (note: I have concealed my actual domain names):

Activating privacy features...2016/11/21 07:47:41 [www.example.com] failed to get certificate: acme: Error 403 - urn:acme:error:unauthorized - Invalid response from http://www.example.com/.well-known/acme-challenge/ALmqQ8Vl5fvPF91tvqw2zigHlPoRRgTGR2GaLtgX3-A [134.92.240.68]: 404

Caddy prints more detail essentially repeating the same information, then it terminates.

like image 584
Rick-777 Avatar asked Nov 21 '25 08:11

Rick-777


1 Answers

In order to serve multiple subdomains, you can add them seperately to your Caddyfile. Caddy will request a distinct SSL certificate from Let's Encrypt for each domain name.

example.com {
  ...
}

www.example.com {
  ...
}

test.example.com {
  ...
}

→ 3 distinct certificates: [example.com] [www.example.com] [test.example.com]

You can combine multiple addresses that share the same configuration like you did in your example, but Caddy will still request one SSL certificate from Let's Encrypt for each specified domain name.

www.example.com, test.example.com {
  ...
}

→ 2 distinct certificates: [www.example.com] [test.example.com]

like image 76
Nikolas Evers Avatar answered Nov 24 '25 09:11

Nikolas Evers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!