1. Caddy version (caddy version
):
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
via local executable, eg:
./caddy run --config caddy_config.json
I’m using Caddy to expose my local environment to the internet (required for oAuth service redirects and webhooks).
a. System environment:
Ubuntu 18.04 vagrant
b. Command:
./caddy run --config caddy_config.json
d. My complete Caddyfile or JSON config:
{"apps":{"http":{"servers":{"tunnelsh":{"listen":[":443",":80"],"routes":[{"@id":"procfu.lcldev.globi.ca-9001","handle":[{"handler":"reverse_proxy","upstreams":[{"dial":":9001"}]}],"match":[{"host":["procfu.lcldev.globi.ca"]}]}]}}}}}
3. The problem I’m having:
Caddy is not returning HTTP status messages.
With this PHP script:
header("HTTP/1.1 500 foo bar baz");
exit();
I expect and get, when accessing directly:
$ curl -v procfu.vg18/tinker/headers.php
* Trying 192.168.33.22:80...
* TCP_NODELAY set
* Connected to procfu.vg18 (192.168.33.22) port 80 (#0)
> GET /tinker/headers.php HTTP/1.1
> Host: procfu.vg18
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 foo bar baz
< Date: Thu, 02 Dec 2021 14:11:51 GMT
< Server: Apache/2.4.29 (Ubuntu)
< Set-Cookie: PHPSESSID=2lc4dba04goh7337no10u3cnf5; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Content-Length: 0
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
* Closing connection 0
But through Caddy Reverse Proxy, the error text is stripped out:
$ curl -v procfu.lcldev.globi.ca/tinker/headers.php
* Trying 128.199.1.162:80...
* TCP_NODELAY set
* Connected to procfu.lcldev.globi.ca (128.199.1.162) port 80 (#0)
> GET /tinker/headers.php HTTP/1.1
> Host: procfu.lcldev.globi.ca
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Cache-Control: no-store, no-cache, must-revalidate
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< Date: Thu, 02 Dec 2021 14:11:35 GMT
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Pragma: no-cache
< Server: Caddy
< Server: Apache/2.4.29 (Ubuntu)
< Set-Cookie: PHPSESSID=qi6ipj0hsnkinsmj6hdrpicipl; path=/
<
* Connection #0 to host procfu.lcldev.globi.ca left intact
In Chrome/Firefox there is no status message text at all.
This makes it impossible for client-side JavaScript to properly deal with errors.
How can I get the message text to pass through with the status code?
Note: everything works fine without Caddy. Production servers through a load balancer return the correct status message, public dev servers return the correct status message, and my local vagrant returns the correct status message when accessed directly.
It’s only when accessing via Caddy’s reverse proxy that the status message is stripped out.