Open WillPlatnick opened 1 month ago
This is an artifact of how the Go resolver works. It first consults with /etc/hosts
, then uses the specified upstream resolver if it's not found. I'm trying to think what would be the best course of action for this scenario. Honestly, your setup is odd. Any good reason for that? How could your DNS server know the path anyways? This doesn't appear like a split-horizon setup.
Anyways, I know this feature was developed per a sponsor request. We'll have to check the original requirements and see where to go from there given this report.
Hello, Caddy v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk= installed via homebrew on macOS
I am trying to setup a local reverse proxy that is doing path-based routing on the same domain, and resolving the host to different IP's, depending on the path.
Here is my Caddyfile
I have a DNS server running on 127.0.0.1 that resolves my.site.com to a specific IP. This works properly. 1.1.1.1 isn't the real IP, I just redacted it.
I am testing using the following curl
curl https://my.site.com/mypath/ --resolve my.site.com:443:127.0.0.1 -v
If I don't have
127.0.0.1 my.site.com
in my /etc/hosts - the setup works perfectlyI get a log showing DNS worked as it should:
However, once I add
127.0.0.1 my.site.com
to my /etc/hosts, Caddy resolves the DNS to 127.0.0.1, rather than using the specified resolver:I further verified it's taking the hosts file entry by setting it to 127.0.0.2 in the hosts file, and I get this in the logs: