1. The problem I’m having:
I am trying to set a cache-control header based on a file type in a path. I tried this:
But putting this within the handler didn’t work and of course this is a reverse_proxy so it needs to be header_down. If I use this, it works but of course for all files which is not what I want.
@nocache {
file *.txt
}
handle {
reverse_proxy https://192.168.73.49:8080 {
transport http {
dial_timeout 30s # Experimental
tls_insecure_skip_verify
}
header_down cache-control no-store
}
}
The path in question is https://tester1.camdenacres.stream/static/status.txt
Things I have tried:
@nocache {
file
path *.txt
}
handle {
reverse_proxy https://192.168.73.49:8080 {
transport http {
dial_timeout 30s # Experimental
tls_insecure_skip_verify
}
header_down @nocache cache-control no-store
}
}
handle {
reverse_proxy https://192.168.73.49:8080 {
transport http {
dial_timeout 30s # Experimental
tls_insecure_skip_verify
}
header_down @nocache cache-control no-store
}
@nocache {
file *.txt
}
}
Several other permutations.
2. Error messages and/or full log output:
N/A - This is a config issue.
3. Caddy version:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
4. How I installed and ran Caddy:
Docker compose
version: "3.6"
services:
Caddy:
container_name: "Caddy"
hostname: "Caddy"
image: "caddy:latest"
logging:
driver: "json-file"
options:
max-size: "100m"
networks:
- "Docker1"
ports:
- "443:443/tcp"
- "80:80/tcp"
restart: "unless-stopped"
volumes:
- "/opt/caddy/html:/var/caddy/html:ro"
- "/opt/caddy:/etc/caddy:ro"
networks:
Docker1:
external: true
name: "Docker1"
a. System environment:
Debian 11.7 running Docker 23.0.1
b. Command:
See docker-compose aobve
c. Service/unit/compose file:
See above
d. My complete Caddy config:
https://tester1.camdenacres.stream {
handle_path /errors* {
root * /var/caddy/html
file_server
}
@nocache {
file *.txt
}
handle {
reverse_proxy https://192.168.73.49:8080 {
transport http {
dial_timeout 30s # Experimental
tls_insecure_skip_verify
}
header_down @nocache cache-control no-store
}
}
handle_errors {
@502 `{err.status_code} == 502`
handle @502 {
root * /var/caddy/html
rewrite * /502.html
file_server
}
}
}