Caddy redirecting all subdomains to the first one mentioned in Caddyfile?

1. The problem I’m having:

Caddy redirects all 3 subdomains to the first subdomain specified in the Caddyfile. (for no apparent reason).

I have 3 subdomains. Each needs to be directed to a different port. However, all 3 are redirecting to the same port.

I own the domain with Google Domains, and I have dynamic DNS set up to link all 3 subdomains to my machine. I’ve verified with curl that the network side of things is working. All ports are accessible, including 443/80. I can connect directly to each service locally or publicly, when I specify the ip/port.

2. Error messages and/or full log output:

I don’t spot any error, it appears normal. (I replaced my domain with “domain”)

2023/05/22 09:23:58.493	e[34mINFOe[0m	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2023/05/22 09:23:58.495	e[34mINFOe[0m	tls.cache.maintenance	started background certificate maintenance	{"cache": "0xc000922a10"}
2023/05/22 09:23:58.495	e[34mINFOe[0m	http	server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS	{"server_name": "srv0", "https_port": 443}
2023/05/22 09:23:58.495	e[34mINFOe[0m	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv0"}
2023/05/22 09:23:58.496	e[34mINFOe[0m	tls	cleaning storage unit	{"description": "FileStorage:C:\\Users\\paul\\AppData\\Roaming\\Caddy"}
2023/05/22 09:23:58.496	e[34mINFOe[0m	http	enabling HTTP/3 listener	{"addr": ":443"}
2023/05/22 09:23:58.496	e[34mINFOe[0m	http.log	server running	{"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/05/22 09:23:58.496	e[34mINFOe[0m	http.log	server running	{"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2023/05/22 09:23:58.496	e[34mINFOe[0m	http	enabling automatic TLS certificate management	{"domains": ["plex domain com", "mc domain com", "ebooks domain com"]}
2023/05/22 09:23:58.499	e[34mINFOe[0m	autosaved config (load with --resume flag)	{"file": "C:\\Users\\paul\\AppData\\Roaming\\Caddy\\autosave.json"}
2023/05/22 09:23:58.499	e[34mINFOe[0m	serving initial configuration
2023/05/22 09:23:58.501	e[34mINFOe[0m	tls	finished cleaning storage units

3. Caddy version:

v2.6.4 - Windows 10 with Google DNS Packages added

4. How I installed and ran Caddy:

I installed it from caddyserver.org after adding my packages. I then ran it in cmd with ‘caddy.exe run’ after renaming the file.

a. System environment:

Windows 10 - AMD64

b. Command:

caddy.exe run

c. Service/unit/compose file:

no idea what this is.

d. My complete Caddy config:

(note, domainname is my domain. periods removed because I can’t post them.)

{
	acme_dns google_domains (apikey)
 
 
domain1 domainname com {
    reverse_proxy localhost:32400
}
 
domain2 domainname com {
    reverse_proxy localhost:32401
}
 
domain3 domainname com {
    reverse_proxy localhost:32402
}
 
}

5. Links to relevant resources:

Disabling IPv6 in network adapter options fixed this.

Does anyone know why that is the case?

Your Caddyfile has invalid syntax, it seems. Your braces aren’t in the right place.

Show an example of the behaviour you’re seeing with curl -v.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.