1. Output of caddy version
:
caddy:2.6.2-alpine
2. How I run Caddy:
a. System environment:
Docker compose
b. Command:
docker compose up -d
c. Service/unit/compose file:
services:
caddy:
image: caddy:2.6.2-alpine
restart: unless-stopped
hostname: caddy
ports:
- "80:80"
- "443:443"
networks:
- caddy
volumes:
- $PWD/Caddyfile:/etc/caddy/Caddyfile
- $PWD/site:/srv
- caddy_data:/data
- caddy_config:/config
cityguide:
image: crmejia/cityguide:latest
restart: always
hostname: cityguide
ports:
- "8080:8080"
networks:
- caddy
volumes:
- cityguide-db:/root
volumes:
caddy_data:
caddy_config:
cityguide-db:
networks:
caddy:
d. My complete Caddy config:
{
#auto_https off
#auto_https disable_redirects
email email@gmail.com
}
:80 {
reverse_proxy cityguide:8080
}
3. The problem I’m having:
I cannot reverse_proxy my web app. My app is running on port 8080 and caddy is running on port :80.
4. Error messages and/or full log output:
{"level":"error","ts":1673024105.4303176,"logger":"http.log.error","msg":"dial tcp :8080: connect: connection refused","request":{"remote_ip":"172.23.0.1","remote_port":"55388","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"User-Agent":["curl/7.79.1"],"Accept":["*/*"]}},"duration":0.000485339,"status":502,"err_id":"5a68804ej","err_trace":"reverseproxy.statusError (reverseproxy.go:1272)"}.
$ curl -I localhost:80
HTTP/1.1 502 Bad Gateway
Server: Caddy
Date: Fri, 06 Jan 2023 17:24:36 GMT
5. What I already tried:
I’ve found this post cannot get reverse proxy to work on localhost with docker-compose that details my exact problem but even after following I cannot get it to work.
I can successfully curl localhost:8080
and get the web app. I’ve also ran my app as a container and caddy locally(MacOS) and was able to make it work that way.