1. Caddy version (caddy version
):
v2.4.6
2. How I run Caddy:
Inside a Docker container, my node.js application sits in another container
a. System environment:
MacOs Monterey 12.2.1
Docker desktop 4.5.0
b. Command:
docker run -d --name caddy -p 80:80 -p 443:443 -p 2019:2019 <c>
c. Service/unit/compose file:
version: "3.9"
services:
woodbit-pro:
container_name: woodbit-pro
build:
context: .
dockerfile: Dockerfile-pro
expose:
- "80"
- "443"
d. My complete Caddyfile or JSON config:
{
"apps": {
"http": {
"servers": {
"localhost": {
"listen": [":443"],
"routes": [
{
"match": [
{
"host": ["localhost"]
}
],
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "172.18.0.2:5001"
}
]
}
]
}
]
}
}
}
}
}
3. The problem I’m having:
I am trying to run the app on localhost, it is accessible on localhost:5001, I want the caddy to do a reverse proxy to it, the ip address in the upstream is the ip of the docker container running the app.
4. Error messages and/or full log output:
It does not work, in Chrome network when going to localhost, it redirects to https://localhost but then responds with
Failed to load resource: the server responded with a status of 502 ()
5. What I already tried:
Tried a lot of variations, with no result.
Thanks for helping: my problem is of course lack of knowledge as a beginner.
But I also did not find a json example of reverse proxy to other docker container.