1. Caddy version (caddy version
):
v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=
2. How I run Caddy:
I run Caddy in a multi-container docker-compose setup.
a. System environment:
Ubuntu 20.04, Docker 19.03.13
b. Command:
docker-compose up proxy
c. Service/unit/compose file:
proxy:
image: caddy:2-alpine
restart: always
ports:
- 80:80
- 443:443
volumes:
- caddy_data:/data
- caddy_config:/config
- ./Caddyfile:/etc/caddy/Caddyfile
logging:
driver: syslog
options:
tag: caddy
d. My complete Caddyfile or JSON config:
static.example.com {
reverse_proxy minio:9000
route expression {uri}.endsWith("/") {
rewrite {uri}index.html
}
rewrite * /static/{uri}
log
}
3. The problem I’m having:
I would like to proxy a MinIO installation that contains a static website
in a public bucket called static
. MinIO does not know how to serve static websites
(i.e. serving index.html) so I would like to rewrite all /path/to/something/
requests to /static/path/to/something/index.html
while everything else
gets rewritten to /static/{uri}
without appending index.html
.
From what I understand my rules from my Caddyfile should apply one rewrite for
an asset like https://static.example.com/script.js
and two rewrites for
https://static.example.com/blog/
. However, it looks as if both rewrites get
applied to all requests as https://static.example.com/blog/
returns the correct
index document when https://static.example.com/script.js
does return 404. Both
resources exist in the bucket.
When I remove the route
block from my config, I can access
https://static.example.com/script.js
, but https://static.example.com/blog/
will 404.
4. Error messages and/or full log output:
n/a
5. What I already tried:
Using the given Caddyfile. I also tried using path_regexp matcher with the same
result.
6. Links to relevant resources:
This is a Caddy v1 issue on the same topic ecosystem: Add a caddy plugin to serve static files from Minio server. · Issue #3161 · minio/minio · GitHub