1. Caddy version (caddy version
):
v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
2. How I run Caddy:
Google VPS
a. System environment:
Ubuntu 18.04
b. Command:
paste command here
c. Service/unit/compose file:
**caddy.service**
# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
domain.com {
root * /var/www/domain.com
encode zstd gzip
php_fastcgi unix//run/php/php7.2-fpm.sock
file_server
}
3. The problem I’m having:
I get an error 502 on accessing the webpage, HTML works fine though.
4. Error messages and/or full log output:
var/log/syslog says;
Jun 13 11:57:07 web-server caddy[9391]: {"level":"error","ts":1592045827.215587,"logger":"http.log.error","msg":"dialing backend: dial unix /run/php/php7.2-fpm.sock: connect: permission denied","request":{"method":"GET","uri":"/","proto":"HTTP/2.0","remote_addr":"xx.xx.xx.xx:54309","host":"domain.com","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Edg/83.0.478.45"],"Sec-Fetch-Dest":["document"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Site":["none"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-User":["?1"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-GB,en;q=0.9,en-US;q=0.8"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"domain.com"}},"duration":0.000390501,"status":502,"err_id":"zyv7e106q","err_trace":"reverseproxy.(*Handler).ServeHTTP (reverseproxy.go:380)"}
/etc/php/7.2/fpm/pool.d/www.conf says;
listen = /run/php/php7.2-fpm.sock
5. What I already tried:
sudo reboot
sudo service caddy restart
sudo service php7.2-fpm restart
6. Links to relevant resources:
My issue is exactly like this one but following this thread doesn’t resolve the issue.