Docker Caddy Static Files does not update

1. The problem I’m having:

I have a directory proxy with static files, I change content, or rename but still does not update changes, I tried restart, browser cache, etc, but I can´t solve my problem

All proxy work fine

  1. Access to http://portales.local/Demo/config/igni.json works fine
    image

  2. I’m try change values for igni.json but still not update, trying query params

  3. I try rewrite condition and rename file but not working , I cant access to igni2.json

rewrite /Demo/config/igni2.json /igni2.json

  1. I try change domain to portales.local.com

  2. I trying GET https://portales.local.com/Demo/config/igni2.json does not working but if i try old one https://portales.local.com/Demo/config/igni.json the same value

How can I solve, thank you

2. Error messages and/or full log output:

2024-03-16T04:38:22.107025148Z {"level":"info","ts":1710563902.106991,"msg":"serving initial configuration"}
2024-03-16T04:38:22.200577547Z {"level":"warn","ts":1710563902.2004135,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"99d3fb7d-1116-498b-8a4b-ad1c22977bb9","try_again":1710650302.2004113,"try_again_in":86399.999999547}
2024-03-16T04:38:22.200606436Z {"level":"info","ts":1710563902.2005546,"logger":"tls","msg":"finished cleaning storage units"}
{"level":"info","ts":1710563902.2005546,"logger":"tls","msg":"finished cleaning storage units"}
{"level":"debug","ts":1710564002.4846964,"logger":"http.handlers.rewrite","msg":"rewrote request","request":{"remote_ip":"172.29.0.1","remote_port":"41420","client_ip":"172.29.0.1","proto":"HTTP/1.1","method":"GET","host":"portales.local","uri":"/Demo/config/igni.json?run=cache","headers":{"Accept-Language":["es-419,es;q=0.9"],"Cookie":[],"Connection":["keep-alive"],"Pragma":["no-cache"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Cache-Control":["no-cache"],"Upgrade-Insecure-Requests":["1"],"Accept-Encoding":["gzip, deflate"]}},"method":"GET","uri":"/config/igni.json?run=cache"}
{"level":"debug","ts":1710564002.48505,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"angular:4200","total_upstreams":1}
{"level":"debug","ts":1710565329.770169,"logger":"http.handlers.rewrite","msg":"rewrote request","request":{"remote_ip":"172.29.0.1","remote_port":"36724","client_ip":"172.29.0.1","proto":"HTTP/1.1","method":"GET","host":"portales.local","uri":"/Demo/config/igni2.json?asas","headers":{"Connection":["keep-alive"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["es-419,es;q=0.9"],"Cookie":[]}},"method":"GET","uri":"/config/igni2.json?asas"}


3. Caddy version:

caddy:2.7.6-alpine

4. How I installed and ran Caddy:

Docker

a. System environment:

Fedora 38, Docker

b. Command:

docker-compose up -d

c. Service/unit/compose file:

services:
  proxy:
    container_name: portal-caddy
    image: caddy:2.7.6-alpine
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./www/:/home/www/

d. My complete Caddy config:

{
	debug
	auto_https off
}

http://portales.local {
	header Access-Control-Allow-Credentials "true"
	header Access-Control-Allow-Headers "*"
	header Access-Control-Allow-Source-Origin "*"
	header Cache-Control "no-cache, no-store, must-revalidate"

	handle_path /Demo* {
		root * /home/www
		file_server
		rewrite /Demo/config/igni.json /igni.json

		reverse_proxy http://angular:4200
	}

	reverse_proxy http://next:3000
}

/home/www/igni.json

{
    "demo"   : "value",
    "demo2"   : "value"
}

5. Links to relevant resources:

The problem is that you stripped /Demo with handle_path, so your rewrite doesn’t match because the path no longer has /Demo on it. You’d need to match /config/igni.json instead.

Also, your config as-is doesn’t really make sense; you shouldn’t have both file_server and reverse_proxy in the same route without having a matcher to separate them. As-is, reverse_proxy is higher on the directive order, so all requests will hit your proxy and not your file server.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.