1. Caddy version (caddy version
):
Whatever the caddy image being pulled by the below docker compose:
2. How I run Caddy:
Docker
a. System environment:
Raspberry Pi 3 with Docker.
b. Command:
c. Service/unit/compose file:
version: "3.8"
services:
caddy:
image: caddy
container_name: caddy
hostname: caddy
env_file: ../.env
restart: unless-stopped
ports:
- "80:80"
- "443:443"
environment:
- DOMAIN
- DOMAIN_LOCAL
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- ./data:/data
- ./config:/config
networks:
default:
external:
name: $NETWORK
d. My complete Caddyfile or JSON config:
{
# acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}
portainer.{$DOMAIN} portainer.{$DOMAIN_LOCAL} {
reverse_proxy portainer:9000
}
home.{$DOMAIN} home.{$DOMAIN_LOCAL} {
reverse_proxy homeassistant:8123
}
3. The problem I’m having:
When i replace homeassistant
with 192.168.1.100
(which is the local IP of the Raspberry Pi running caddy, portainer, and home assistant docker containers) in the home.
route the caddy reverse proxy works perfect and resolves to the home assistant docker container.
But the portainer:9000
works fine! It perfectly routes the portainer. subdomian to the docker container on the Pi.
Here is my docker-compose for portainer
which works great with the caddyFile
version: '3.8'
services:
portainer:
image: portainer/portainer
container_name: portainer
hostname: portainer
env_file: ../.env
command: -H unix:///var/run/docker.sock
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
ports:
- 9000:9000
networks:
default:
external:
name: $NETWORK
Here is my homeassistant
docker-compose:
version: '3.8'
services:
homeassistant:
image: homeassistant/raspberrypi3-homeassistant:stable
container_name: homeassistant
hostname: homeassistant
env_file: ../.env
network_mode: host # exposes all ports, needed for multicast DNS
restart: always
volumes:
- ./config:/config
devices:
- /dev/ttyUSB0:/dev/ttyUSB0:rwm
- /dev/ttyUSB1:/dev/ttyUSB1:rwm
networks:
default:
external:
name: $NETWORK
As you can see they are both connected to the same docker network which i have created externally and both reference using the the same .env
file.
4. Error messages and/or full log output:
502 bad gateway when i try to use homeassistant:8123
instead of 192.168.1.100:8123
.
5. What I already tried:
I have found out that putting the local IP works, this doesn’t seem to be caused by home assistant because keeping it’s config the same and changing the reverse proxy route works.
Is this due to the network_mode: host
?