1. Caddy version (caddy version
):
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=
(but originally noticed with same result in v1.0.3 (h1:i9gRhBgvc5ifchwWtSe7pDpsdS9+Q0Rw9oYQmYUTw1w=)
2. How I run Caddy:
Docker with php-fpm: GitHub - ComaVN/caddy-http-status-poc
(Same result when using the abiosoft/caddy:php-no-stats docker image)
a. System environment:
Docker version 20.10.5 on Ubuntu 20.04.2 LTS, using the caddy:2.3.0-alpine
image
b. Command:
See the README:
docker build --target caddy --tag caddy-http-status-poc . \
&& docker run --rm -p8080:8080 caddy-http-status-poc
curl -v http://localhost:8080
c. Service/unit/compose file:
#!/bin/sh
set -e
kill_handler() {
echo "kill signal received"
kill -TERM "$child"
}
trap kill_handler TERM INT
php-fpm7
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile &
child=$!
wait "$child"
d. My complete Caddyfile or JSON config:
:8080
# Set this path to your site's directory.
root * /srv
# Enable the static file server.
file_server
php_fastcgi localhost:9000
3. The problem I’m having:
I use Caddy to mock the API of certain hardware devices, for use in dev & test. This particular piece of hardware decided to start returning non-standard HTTP status lines (eg. HTTP/1.1 400 key expired
). This means my mock needs to return the same non-standard reasons, so I can properly test my code.
However, Caddy seems to always return the reason-phrase from the RFC, ie. Bad Request
, regardless of what header my PHP writes.
When using PHP’s own dev webserver (php -S
) or nginx, the header is “properly” returned as-is.
4. Error messages and/or full log output:
None, really. See the README
5. What I already tried:
I have tried using different php functions to return the header (ie. http_response_code
or header
), and different web servers. I really like Caddy’s easy TLS support tho…
I have looked at handle_errors
and such, but that seems to be more about changing the status code & body, not the reason-phrase.