Continuing the discussion from Discourse with Caddy v2 on Docker:
1. Caddy version (2.0 / 2.1.0 beta
):
2. How I run Caddy:
a. System environment:
Docker on Ubuntu 20.04
b. Command:
docker-compose up
c. Service/unit/compose file:
version: '3.3'
services:
caddy:
# env_file:
# - .env
container_name: caddy
build: .
ports:
- "80:80"
- "443:443"
- "80:80/udp"
- "443:443/udp"
volumes:
- /var/discourse/shared/web-only:/sock
- /var/caddy/Caddyfile:/etc/caddy/Caddyfile
- /var/caddy:/root/.caddy
- /var/caddy/data:/data
- /var/caddy/config:/config
restart: always
wp1:
env_file:
- .env
image: $WP_IMAGE
container_name: wordpress
hostname: dev.xxxxxxxx.com
# ports:
# - 8080:80
# depends_on:
# - db1
restart: always
environment:
WORDPRESS_DB_HOST: db1
WORDPRESS_DB_USER: wpdrone
WORDPRESS_DB_PASSWORD: $MYSQL_PASS_1
WORDPRESS_DB_NAME: db-wp1
volumes:
- /var/www/wp1:/var/www/html
db1:
env_file:
- .env
image: $DB_IMAGE
restart: always
environment:
MYSQL_DATABASE: db-wp1
MYSQL_USER: wpdrone
MYSQL_PASSWORD: $MYSQL_PASS_1
MYSQL_ROOT_PASSWORD: $MYSQL_PASS_1
# MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- /var/mysql/wp1:/var/lib/mysql
d. My complete Caddyfile or JSON config:
Working v1 Caddyfile, basically
forums.example.com {
proxy / unix:/sock/nginx.http.sock {
transparent
}
}
dev.example.com {
proxy / wordpress {
transparent
}
}
v2 Caddyfile, actual
{
debug
}
forum.xxxxxxxx.com {
reverse_proxy unix//sock/nginx.http.sock
tls {
dns cloudflare APIKEY
}
}
dev.xxxxxxxx.com {
# root * /var/www/wp1
# root * /var/www/html
reverse_proxy / wordpress
# php_fastcgi / wp1
# reverse_proxy wordpress
# php_fastcgi wordrpess
# php_fastcgi wordrpess:9000
tls {
dns cloudflare APIKEY
}
}
3. The problem I’m having:
This is an attempt to move from working v1 to v2.x.
Discourse is working via the same Caddy docker-compose
, but I get a blank page for Wordpress. Internal network issue?
I was getting apache errors from the Wordpress service about it not being able to determing the FQDN before specifying via this line in docker-compose
. Not sure if something changed (I’ve never needed that before), or if it’s a symptom of another error:
hostname: dev.xxxxxxxx.com
…after adding that, all service containers build with no error messages.
Of course, these bits of the error log stand out, because they’re similar to the problem I was having with the Discourse setup, which ended up being a syntax error. But I’m not even finding a backslash to change.
upstream wordpress:: invalid dial address wordpress:: invalid start port: strconv.ParseUint: parsing \"\": invalid syntax"
Full error log below
4. Error messages and/or full log output:
invalid dial address, etc.
caddy | {“level”:“error”,“ts”:1593380833.556185,“logger”:“http.log.error”,“msg”:“making dial info: upstream wp1:: invalid dial address wp1:: invalid start port: strconv.ParseUint: parsing "": invalid syntax”,“request”:{“method”:“GET”,“uri”:“/”,“proto”:“HTTP/1.1”,“remote_addr”:“172.68.132.228:44600”,“host”:“dev.xxxxxxxx.com”,“headers”:{“Cookie”:[“__cfduid=dc88b5462c50f9e7efa2c00ee103b2a071593329757”],“Cf-Connecting-Ip”:[“2001:5b0:49cc:8b0c:49e8:6443:305d:48f8”],“X-Forwarded-For”:[“2001:5b0:49cc:8b0c:49e8:6443:305d:48f8”],“X-Forwarded-Proto”:[“https”],“Accept”:[“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”],“Cf-Visitor”:[“{"scheme":"https"}”],“User-Agent”:[“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0”],“Upgrade-Insecure-Requests”:[“1”],“Cf-Request-Id”:[“039e7f20ed000002df5f066200000001”],“Accept-Encoding”:[“gzip”],“Cf-Ray”:[“5aaa9ae17a0302df-SJC”],“Connection”:[“Keep-Alive”],“Dnt”:[“1”],“Cache-Control”:[“max-age=0”],“Cf-Ipcountry”:[“US”],“Accept-Language”:[“en-US,en;q=0.5”],“Cdn-Loop”:[“cloudflare”]},“tls”:{“resumed”:false,“version”:772,“ciphersuite”:4867,“proto”:“”,“proto_mutual”:true,“server_name”:“dev.xxxxxxxx.com”}},“duration”:0.000070497}
5. What I already tried:
- Building from Caddy v2.0.0 and v2.1.0 beta Docker images. Both seem to build fine. Side-note: v2.1.0 is released on regular builds. I don’t see a non-beta in Docker hub yet. Is that pending?
- Wordpress default (apache) and
wordpress:php7.4-fpm
. The FPM image seems to respond similarly whether I usephp_fastcgi
orreverse_proxy
inCaddyfile
. Pretty sure I was getting the same errors at from both at one point, but currently I don’t get errors with FPM, its just doesn’t seem to do anything. - Various syntax, for example
reverse_proxy / wp1
vs.reverse_proxy wp1
- Commented variations in Caddyfile and docker-compose.yml.
- Referencing variations in Docker network hostnames in Caddyfile. For example, the service name, specifying a container name in compose, using the name reported by Docker (usually has
_1
appended to the service name), etc. - I dunno. I’ve now been shuffling bits and pieces around since yesterday.
Compose output for wordpress fpm:
wordpress | [28-Jun-2020 23:02:19] NOTICE: fpm is running, pid 1
wordpress | [28-Jun-2020 23:02:19] NOTICE: ready to handle connections
And for wordpress apache:
wordpress | [Sun Jun 28 23:13:35.526415 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.7 configured -- resuming normal operations
wordpress | [Sun Jun 28 23:13:35.526536 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
6. Links to relevant resources:
Thread where I eventually had this working in v1 2 years ago: