1. Caddy version (caddy version
):
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=
2. How I run Caddy:
Docker Compose with Docker for Mac.
a. System environment:
OS X Big Sur 11.2.2 (20D80)
b. Command:
caddy run --config /etc/caddy/config.json --resume
c. Service/unit/compose file:
version: "3"
services:
caddy:
image: caddy
command: [ 'caddy', 'run', '--config', '/etc/caddy/config.json', '--resume' ]
ports:
- 127.0.0.1:8080:80
- 127.0.0.1:2019:2019
volumes:
- ./caddy/config.json:/etc/caddy/config.json
d. My complete Caddyfile or JSON config:
{
"admin": {
"disabled": false,
"listen": "0.0.0.0:2019"
},
"apps": {
"http": {
"servers": {
"sites": {
"listen": [
":80"
],
"routes": [
{
"group": "site_daa01c0b-8b74-4098-9107-05592ad89eae",
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "headers",
"response": {
"set": {
"Cache-Control": [
"public",
"max-age=0",
"must-revalidate"
]
}
}
},
{
"encodings": {
"gzip": {
"level": 1
}
},
"handler": "encode",
"minimum_length": 0
},
{
"handler": "static_response",
"body": "Hi !"
}
]
}
]
}
],
"match": [
{
"host": [
"main.localhost"
]
}
]
}
]
}
}
}
}
}
3. The problem I’m having:
When using the encode
handle configured with gzip
, I’m not seeing any Content-Encoding
headers added to the response. The docs mention that an encoding is selected when the Accept-Encoding
header is present. I’m assuming that when a single encoding is configured and no header is set, Caddy uses the only encoding configured.
4. Error messages and/or full log output:
5. What I already tried:
I thought maybe the handler was used in the wrong place, but in the docs it seems it’s always used before the file_server
handler.