Caddy v2 set host other than listen

I’m trying to configure Caddy v2 on a server sitting behind a NAT which forwards port 443 to it.
Problem is, if I try to get automatic HTTPs to work by just saying “listen”: [“my.domain:443”] the server tries to bind to the IP of the router (and fails).

Is there a way to separate the “bind to this port” and the “use this domain” parts of the config?

Hey @gigaroby – absolutely; you want a host matcher. So just use “:443” as your listen address, then specify the host matcher with "" (or whatever) in it.

Or the equivalent Caddyfile:

If you run caddy adapt on that, you’ll see what I mean.

1 Like

This topic was automatically closed after 180 days. New replies are no longer allowed.