1. My Caddy version (caddy version
):
(devel)
2. How I run Caddy:
/usr/local/bin/caddy run --environ --config /etc/caddy/Caddyfile
a. System environment:
CentOS 8
d. My complete Caddyfile or JSON config:
domain.tld:443 {
root * /var/www/public
encode gzip
tls echelon@domain.tld
header / {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always
# connect via HTTPS (do not use if only testing)
Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
X-Content-Type-Options "nosniff"
Access-Control-Allow-Origin *
Access-Control-Allow-Methods "GET, POST, OPTIONS"
-Server
}
php_fastcgi unix//var/run/php-fpm/www.sock
file_server
log {
output file /var/log/caddy/access.log
format single_field common_log
}
handle_errors {
@404 {
expression {http.error.status_code} == '404'
}
respond @404 "Oops 404 Try again"
}
}
3. The problem I’m having:
When trying to access non-exist-an php file, caddy serving the “File not found.” response from the php-fpm, instead of 404 erros
4. Error messages and/or full log output:
File not found.
5. What I already tried:
Adding handle_errors as above.
The question is how to serve 404 error page if php-fpm cannot find the php files ?