Caddy v2 Throwing 502 Error

I just set up Syncthing with the instructions I found at How to Install Syncthing on Ubuntu Desktop/Server

I also have Caddy v2 running via Docker-Compose. The portion for Syncthing is:

sync.domain.me {
    reverse_proxy http://localhost:8384
}

However, when I try to access Syncthing through my domain, it returns with error 502.

Looking at the logs of Caddy, I see

{"level":"error","ts":1620763248.9051778,"logger":"http.log.error","msg":"dial tcp 127.0.0.1:8384: connect: connection refused","request":{"remote_addr":"192.168.1.1:55860","proto":"HTTP/2.0","method":"GET","host":"sync.domain.me","uri":"/","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51"],"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-Site":["none"],"Cache-Control":["max-age=0"],"Sec-Ch-Ua-Mobile":["?0"],"Dnt":["1"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en;q=0.9"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Microsoft Edge\";v=\"90\""],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Mode":["navigate"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"sync.domain.me"}},"duration":0.000789035,"status":502,"err_id":"1s45kz59n","err_trace":"reverseproxy.statusError (reverseproxy.go:852)"}


{"level":"error","ts":1620763249.7376173,"logger":"http.log.error","msg":"dial tcp 127.0.0.1:8384: connect: connection refused","request":{"remote_addr":"192.168.1.1:55860","proto":"HTTP/2.0","method":"GET","host":"sync.domain.me","uri":"/","headers":{"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Cache-Control":["max-age=0"],"Dnt":["1"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Site":["none"],"Sec-Fetch-Mode":["navigate"],"Accept-Language":["en-US,en;q=0.9"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Microsoft Edge\";v=\"90\""],"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51"],"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"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"sync.domain.me"}},"duration":0.000727367,"status":502,"err_id":"8c3x11uhf","err_trace":"reverseproxy.statusError (reverseproxy.go:852)"}

That’s expected as localhost in a container does not point to your host.

Avoid the headache and install caddy directly :wink:

4 Likes

That makes sense, duh!

Thanks!

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