1. The problem I’m having:
I’m trying to send a request from within a Docker container to my Caddy admin api on the host machine on my Ubuntu server. If I just do curl -v http://172.17.0.1 it connects just fine through port 80, but when doing curl -v http://172.17.0.1:2019 it hangs on Trying 172.17.0.1:2019… forever and the connection doesn’t seem to go through, but it also is not refused either. I have added the port to my firewall with ufw allow from 172.17.0.1 proto tcp to any port 2019, also ran iptables -I DOCKER-USER -i docker0 -p tcp --dport 2019 -j ACCEPT and nft add rule ip filter DOCKER-USER iifname "docker0" tcp dport 2019 accept
Running lsof -iTCP:80 -sTCP:LISTEN:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
caddy 242000 caddy 22u IPv6 2048423 0t0 TCP *:http (LISTEN)
Running lsof -iTCP:2019 -sTCP:LISTEN:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
caddy 242000 caddy 15u IPv6 2048411 0t0 TCP *:2020 (LISTEN)
I thought this was due to the Type being IPv6 but that seems to be the case on port 80 as well, so I don’t know. I have tried multiple configurations and nothing seems to work so I’m coming here for some guidance.
2. Error messages and/or full log output:
Trying 172.17.0.1:2019...
3. Caddy version:
caddy --version
v2.10.2 h1:g/gTYjGMD0dec+UgMw8SnfmJ3I9+M2TdvoRL/Ovu6U8=
4. How I installed and ran Caddy:
I have installed Caddy via xcaddy (v0.4.5_linux_amd64) with the following command:
xcaddy build --with github.com/darkweak/souin/plugins/caddy --with github.com/ueffel/caddy-brotli --with github.com/darkweak/storages/redis/caddy
a. System environment:
Ubuntu 24.04.3 LTS (GNU/Linux 6.8.0-87-generic x86_64)
Running two Docker containers inside, one for WordPress and the other for the React app.
b. Command:
systemctl restart caddy
c. Service/unit/compose file:
services:
remix:
image: my-image
ports:
- "3060:3000"
environment:
- COOKIE_DOMAIN=.mydomain.com
- WP_URI=https://mydomain.com/graphql
restart: always
wordpress:
image: wordpress:latest
ports:
- 8080:80
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
environment:
WORDPRESS_DB_HOST: "****"
WORDPRESS_DB_PORT: ""****"
WORDPRESS_DB_USER: ""****"
WORDPRESS_DB_PASSWORD: "****"
WORDPRESS_DB_NAME: "****"
networks:
carney-network:
driver: bridge
driver_opts:
com.docker.network.driver.mtu: 1400
d. My complete Caddy config:
{
email dev@mydomain.com
admin 0.0.0.0:2019 {
origins http://127.0.0.1:2019 http://localhost:2019 http://172.17.0.0/16 http://172.18.0.0/16
}
# Souin Cache Configuration
order cache before rewrite
cache {
redis {
url localhost:6379
}
ttl 1h
stale 1h
key {
disable_body
disable_host
disable_scheme
disable_vary
hide
}
log_level DEBUG
allowed_http_verbs GET HEAD POST
api {
souin
debug
}
}
}
admin.mydomain.com {
request_body {
max_size 5120MB
}
# Redirect root to /wp-admin
@root path /
redir @root /wp-admin 301
# Proxy all requests to WordPress
reverse_proxy localhost:8080
}
mydomain.com {
encode br gzip
@static_assets {
path_regexp static ^/(assets|lottie)/.*\.(js|css|json)$
}
handle @static_assets {
root * /var/www/static-assets
# Add caching headers
header Cache-Control "public, max-age=31536000"
header Vary "Accept-Encoding"
file_server {
precompressed br gzip
}
}
handle /daily-blog* {
cache {
ttl 24h
stale 48h
}
reverse_proxy localhost:3060
}
handle {
cache {
ttl 7d
stale 14d
}
reverse_proxy localhost:3060
}
}