1. Output of caddy version
:
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=
2. How I run Caddy:
a. System environment:
Ubuntu 22.04.1 LTS with Docker
b. Command:
I’ve tried a number of things, all after running (I know it’s an old version of Wordpress on old PHP, but this is required for my specific use case, unfortunately):
docker build -t wordpress-test wordpress:5.7-php7.4-fpm-alpine
docker run -p 9000:9000 -e [insert working Wordpress database configuration here] wordpress-test
Caddy commands that I’ve tried are:
caddy reverse-proxy --from :8000 --to :9000
caddy run
c. Service/unit/compose file:
FROM wordpress:5.7-php7.4-fpm-alpine
I have this exact Wordpress site running live using wordpress:5.7
, and am using the exact same configuration here, so I’m fairly confident the problem is not with the way I’m configuring Wordpress.
d. My complete Caddy config:
http:// {
php_fastcgi 127.0.0.1:9000
}
3. The problem I’m having:
Nothing that I’ve tried has resulted in a successful HTTP or HTTPS connection. I cannot get any response from Caddy or Wordpress when attempting to load the page. Aside from using PHP-FPM, everything is configured identically to a working Wordpress site that’s deployed using the standard Wordpress Apache Docker image. All I want to do is switch from Apache to Caddy/PHP-FPM, though at this point I’m considering using Nginx instead, just because I’ve got more experience with it.
4. Error messages and/or full log output:
When attempting to use reverse-proxy
:
Server
❯ caddy reverse-proxy --from :8000 --to :9000
2022/12/08 18:34:42.304 WARN admin admin endpoint disabled
2022/12/08 18:34:42.305 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000025420"}
2022/12/08 18:34:42.305 INFO tls cleaning storage unit {"description": "FileStorage:/home/josho/.local/share/caddy"}
2022/12/08 18:34:42.305 INFO tls finished cleaning storage units
2022/12/08 18:34:42.305 INFO autosaved config (load with --resume flag) {"file": "/home/josho/.config/caddy/autosave.json"}
Caddy proxying http://:8000 -> :9000
2022/12/08 18:34:45.756 ERROR http.log.error dial tcp :9000: connect: connection refused {"request": {"remote_ip": "127.0.0.1", "remote_port": "41060", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8000", "uri": "/", "headers": {"User-Agent": ["curl/7.81.0"], "Accept": ["*/*"]}}, "duration": 0.00060134, "status": 502, "err_id": "3niq9u6zt", "err_trace": "reverseproxy.statusError (reverseproxy.go:1196)"}
Client
❯ curl -v localhost:8000
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 502 Bad Gateway
< Server: Caddy
< Date: Thu, 08 Dec 2022 18:34:45 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
When attempting to use php_fastcgi
:
Server
❯ sudo caddy run -config Caddyfile
2022/12/08 18:40:14.728 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": ""}
2022/12/08 18:40:14.729 WARN caddyfile Site block has an unspecified IP address which only matches requests having that Host header; you probably want the 'bind' directive configure the socket {"address": "0.0.0.0"}
2022/12/08 18:40:14.730 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2022/12/08 18:40:14.730 WARN http server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "srv0", "http_port": 80}
2022/12/08 18:40:14.731 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00032bb20"}
2022/12/08 18:40:14.731 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2022/12/08 18:40:14.731 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2022/12/08 18:40:14.731 INFO serving initial configuration2022/12/08 18:40:14.732 INFO tls finished cleaning storage units
Client
❯ curl -v localhost
* Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Thu, 08 Dec 2022 19:05:19 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
5. What I already tried:
I’ve read through the documentation, and tried modifying my configuration based on various topics on this forum and elsewhere, but I suspect that I’m just missing some detail about how FPM and Caddy work together. I am a Python developer who’s inherited this Wordpress site, so other than having a lot of experience with general web development, I’m pretty out of my element with this.