1. Output of caddy version
:
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=
2. How I run Caddy:
a. System environment:
Debian Bullsys
systemd
b. Command:
sudo systemctl start caddy
c. Service/unit/compose file:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
{
email my.email
log {
output file /var/log/caddy/caddy.log
level info
}
}
...
https://fyrfli.org {
log {
output file /var/log/fyrfli-org.log
}
root * /srv/public
encode gzip
php_fastcgi localhost:9000 {
root /srv/public
}
file_server
}
...
Every other host in the Caddyfile works just fine so snipped out those lines for clarity (Itās a long file)
3. The problem Iām having:
When I load up https://fyrfli.org, I get a blank page and the following in the caddy.log file (prettified for readability):
{
"level": "error",
"ts": 1671076650.9727628,
"logger": "http.log.error.log7",
"msg": "dialing backend: dial tcp 127.0.0.1:9000: connect: connection refused",
"request": {
"remote_ip": "69.10.106.221",
"remote_port": "51881",
"proto": "HTTP/2.0",
"method": "GET",
"host": "fyrfli.org",
"uri": "/",
"headers": {
"Accept-Encoding": [
"gzip, deflate, br"
],
"Dnt": [
"1"
],
"Sec-Fetch-User": [
"?1"
],
"Sec-Gpc": [
"1"
],
"Te": [
"trailers"
],
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
],
"Accept-Language": [
"en,en-US;q=0.5"
],
"Sec-Fetch-Dest": [
"document"
],
"Sec-Fetch-Mode": [
"navigate"
],
"Sec-Fetch-Site": [
"none"
],
"User-Agent": [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0"
],
"Upgrade-Insecure-Requests": [
"1"
]
},
"tls": {
"resumed": false,
"version": 772,
"cipher_suite": 4865,
"proto": "h2",
"server_name": "fyrfli.org"
}
},
"duration": 0.000822463,
"status": 502,
"err_id": "givurjirb",
"err_trace": "reverseproxy.statusError (reverseproxy.go:1272)"
}
4. Error messages and/or full log output:
As stated above, error in the caddy log is:
{
"level": "error",
"ts": 1671076650.9727628,
"logger": "http.log.error.log7",
"msg": "dialing backend: dial tcp 127.0.0.1:9000: connect: connection refused",
"request": {
"remote_ip": "my-ip-address",
"remote_port": "51881",
"proto": "HTTP/2.0",
"method": "GET",
"host": "fyrfli.org",
"uri": "/",
"headers": {
"Accept-Encoding": [
"gzip, deflate, br"
],
"Dnt": [
"1"
],
"Sec-Fetch-User": [
"?1"
],
"Sec-Gpc": [
"1"
],
"Te": [
"trailers"
],
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
],
"Accept-Language": [
"en,en-US;q=0.5"
],
"Sec-Fetch-Dest": [
"document"
],
"Sec-Fetch-Mode": [
"navigate"
],
"Sec-Fetch-Site": [
"none"
],
"User-Agent": [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0"
],
"Upgrade-Insecure-Requests": [
"1"
]
},
"tls": {
"resumed": false,
"version": 772,
"cipher_suite": 4865,
"proto": "h2",
"server_name": "fyrfli.org"
}
},
"duration": 0.000822463,
"status": 502,
"err_id": "givurjirb",
"err_trace": "reverseproxy.statusError (reverseproxy.go:1272)"
}
5. What I already tried:
- Iāve tried using the reverse_proxy directive to the :80 port in the docker container.
- Iāve tried adding
try_files {path} {path}/index.php index.php
to the Caddyfile section - Iāve tried adding the container name instead of localhost or 127.0.0.1 or nothing (i.e.
php_fastcgi :9000
I either get the same blank page or a āFile not foundā. However, I can browse the files in the public directory (I was able to load up https://fyrfli.org/robots.txt and see the contents - which is a whole other issue I am going to need to solve later)
6. Links to relevant resources:
I am at my wits end. This is easy with nginx and php-fpm on the host, i.e.:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_read_timeout 30m;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
But I cannot seem to translate this to work with caddy ā php-fpm in a docker container.
Help?!