@francislavoie,
Please help me understand this.
I have a Golang server inside a container that has subdomains.
For the subdomains to work, it needs a valid hostname in the hosts’ file. So I choose localhost
inside the container.
Up to here, it is good.
So far, I can access these routes without Caddy reverse proxy on my laptop:
http://localhost:8000/, http://api.localhost:8000/, & http://api.localhost:8000/tokenv2
Now when I introduce caddy, the subdomains don’t seem to work.
I guess the question is how do access a container’s subdomain inside Caddy?
http://localhost:8080 {
reverse_proxy zipperapiv2:8000
}
http://api.localhost:8080 {
reverse_proxy api.zipperapiv2:8000
}
And the error
caddyserver | {"level":"error","ts":1598300565.317542,"logger":"http.log.error","msg":"dial tcp: lookup api.zipperapiv2 on 127.0.0.11:53: no such host","request":{"method":"GET","uri":"/","proto":"HTTP/1.1","remote_addr":"192.168.224.1:57638","host":"api.localhost:8080","headers":{"Dnt":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-User":["?1"],"Accept-Encoding":["gzip, deflate, br"],"Connection":["keep-alive"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Site":["none"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Dest":["document"],"Accept-Language":["en-GB,en;q=0.9,sw-TZ;q=0.8,sw;q=0.7,en-US;q=0.6"]}},"duration":0.070246047,"status":502,"err_id":"fz0fq5w2a","err_trace":"reverseproxy.(*Handler).ServeHTTP (reverseproxy.go:411)"}