Caddy v2 Reverse proxy returns blank page

1. Caddy version (caddy version):

v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=

2. How I run Caddy:

a. System environment:

Running in docker on a Raspberry Pi 3, using the --network host flag

b. Command:

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config: {
    reverse_proxy localhost:8080
} {
} {

3. The problem I’m having:

I am trying to use the reverse proxy directive to forward the traffic to another machine on the network. The directive works fine if the service is on the same machine as caddy. Whenever I try to forward it to another machine, I get a blank page.

This Caddyfile is not complete, I have a few other services running on another machine and even on that machine I see the blank page.

This setup worked perfectly in Caddy v1, but in Caddy v2 I get a blank page, and a 502 error. The services are all up and I can easily access them from inside the network by using the IP address of the machine.

4. Error messages and/or full log output:

{“level”:“error”,“ts”:1600363452.75425,“logger”:“http.log.error”,“msg”:“dial tcp i/o timeout”,“request”:{“method”:“GET”,“uri”:"/",“proto”:“HTTP/2.0”,“remote_addr”:“”,“host”:“”,“headers”:{“Accept-Language”:[“en-US,en;q=0.5”],“Accept-Encoding”:[“gzip, deflate, br”],“Dnt”:[“1”],“Cache-Control”:[“no-cache”],“Te”:[“trailers”],“Accept”:[“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”],“Upgrade-Insecure-Requests”:[“1”],“Pragma”:[“no-cache”],“User-Agent”:[“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:80.0) Gecko/20100101 Firefox/80.0”]},“tls”:{“resumed”:false,“version”:772,“ciphersuite”:4867,“proto”:“h2”,“proto_mutual”:true,“server_name”:“”}},“duration”:10.001566026,“status”:502,“err_id”:“5i3xdqi6k”,“err_trace”:“reverseproxy.(*Handler).ServeHTTP (reverseproxy.go:411)”}

5. What I already tried:

I tried the following things:

  • caddy validate: Output is clean, the file seems to be correct
  • Tried removing the docker image and using the docker exec on the raspi, nothing changed
  • Checked firewall settings, everything seems to work
  • Read the docs (again and again…)

6. Links to relevant resources:

What happens if you try curl -v from the machine Caddy is running on?

Well…nothing. Looks like the outbound connections to other machines on the LAN are being blocked.

Funnily enough, if I try curl I get the page contents.

So I guess it’s one of these two:

  • Other machines on the network are blocking connections (weird, because it was working just fine)
  • My raspi has some iptables config that is blocking outbound connections to local network

Any ideas on how to proceed? I am a bit lost…

Quick update: I have determined the problem is my router (or at least I expect it to be). I tried to remove all firewall rules, but that did not help. Once a full reboot was performed things started working correctly.

Thanks @francislavoie for putting me on the correct path!


Glad you figured it out! :smile:

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