Help getting caddy reverse proxy working in Windows docker

1. The problem I’m having:

I am trying to get caddy working as a reverse proxy in Windows docker and I’m having some trouble. The Caddy container starts up fine.

I got the domain at Namecheap and created an A record to point to my public IP. If I ping my domain name I get my public IP responding so I know this is working.

When I go to the domain in a web browser nothing shows up in the browser. I expect it to show photoprism, which is what it should be pointing to in my Caddyfile.

Can someone help me out? I’m not new to docker but I’m new to reverse proxies and this is giving me a run for my money.

2. Error messages and/or full log output:

No errors but here is the log from docker when I start it:

2023-11-05 08:07:19 {"level":"info","ts":1699189639.7120357,"msg":"shutting down apps, then terminating","signal":"SIGTERM"}
2023-11-05 08:07:19 {"level":"warn","ts":1699189639.7120962,"msg":"exiting; byeee!! 👋","signal":"SIGTERM"}
2023-11-05 08:07:19 {"level":"info","ts":1699189639.7121816,"logger":"http","msg":"servers shutting down with eternal grace period"}
2023-11-05 08:07:19 {"level":"info","ts":1699189639.71237,"msg":"shutdown complete","signal":"SIGTERM","exit_code":0}
2023-11-05 08:07:20 {"level":"warn","ts":1699189640.5766304,"logger":"admin","msg":"admin endpoint disabled"}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.5767314,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"static","https_port":443}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.5767527,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"static"}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.576954,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.5769885,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000616b00"}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.5771205,"logger":"http.log","msg":"server running","name":"static","protocols":["h1","h2","h3"]}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.5771437,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.577146,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["6384922.xyz"]}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.6031368,"msg":"Caddy serving static files on :443"}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.6032937,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}
2023-11-05 08:07:20 {"level":"info","ts":1699189640.690513,"logger":"tls","msg":"finished cleaning storage units"}

3. Caddy version:

v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=

4. How I installed and ran Caddy:

In Windows Docker

a. System environment:

Windows 11 Docker

b. Command:

docker run -p 80:80 -p 443:443 -p 443:443/udp --name caddy -d -e TZ=America/New_York --cap-add=NET_ADMIN -v C:\DockerConfigs\caddy\data:/data -v C:\DockerConfigs\caddy\config:/config -v C:\DockerConfigs\caddy\Caddyfile\Caddyfile:/etc/caddy/Caddyfile  --restart unless-stopped caddy caddy file-server --domain 6384922.xyz

c. Service/unit/compose file:

Im not using a compose file

d. My complete Caddy config:

6384922.xyz {
	reverse_proxy photoprism:2342
}

1 Like

I just figured it out. Since I cant seem to delete this post Ill post the fix.

I ditched the caddyfile and updated my docker run to this:

docker run -p 80:80 -p 443:443 -p 443:443/udp --name caddy -d -e TZ=America/New_York --cap-add=NET_ADMIN -v C:\DockerConfigs\caddy\data:/data -v C:\DockerConfigs\caddy\config:/config -v C:\DockerConfigs\caddy\Caddyfile\Caddyfile:/etc/caddy/Caddyfile  --restart unless-stopped caddy caddy reverse-proxy --from 6384922.xyz --to 172.17.0.7:2342

I changed ‘file-server’ to ‘reverse-proxy’ and added the from/to parameters.

For some reason I had to use the IP of the docker container in the to instead of the docker container name. Not sure why but its all working as expected now.

1 Like

If you use caddy file-server or caddy reverse-proxy then the Caddyfile is not read. You should use caddy run instead, or just omit the command altogether because that’s already the default command.

Because you’re not actually using docker compose for the Caddy container, and you didn’t put the Caddy container in the same Docker Network at your other container.

1 Like

Ok that makes sense. Thanks for the feedback.

1 Like

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