I have a Caddy server running in Docker talking to a Node.JS server. This setup currently works on MacOS, but does not work on WSL2. I assume the issue has something to do with the fact that we're using http://host.docker.internal:3000
as the proxy address in the Caddyfile, but I don't know of a way to write it so it works on WSL2 and in MacOS.
docker-compose.yml:
version: '3.7'
services:
caddy:
image: 'abiosoft/caddy:latest'
volumes:
- ./certs:/root/certs # to sync mkcert certificates to Caddy
- ./Caddyfile:/etc/Caddyfile # to mount custom Caddyfile
ports:
- '443:2015'
db:
container_name: service_local_db
image: mysql:8.0
environment:
MYSQL_DATABASE: 'service_local'
MYSQL_ROOT_PASSWORD: '******'
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- database_volume:/var/lib/mysql
volumes:
database_volume:
Caddyfile
servicename.url{
log stdout
tls /root/certs/servicename.local.pem /root/certs/servicename.local-key.pem
proxy / http://host.docker.internal:3000 {
websocket
transparent
header_upstream X-Marotagem true
header_upstream Host "servicename.local"
}
}
I have tried:
- Changing
host.docker.internal
tohost-gateway
. Even if that did work, it would inversely not allow it to work on MacOS. - Adding
'host.docker.internal:host-gateway'
asextra_hosts:
underservices
in the docker-compose.yml. It did not work, but if it did I am not sure how it would affect MacOS.
Any help would be appreciated.