1. The problem I’m having:
I need to map everything to a Django/uwsgi reverse proxy except for the media and static files. The problem is the URI needs some modifications before serving the files. Those going to the django/reverse_proxy doesn’t.
The specific cases:
/static/file.png → /home/user1/user1web/user1_static/file.png
/media/files/media.png → /home/user1/user1web/user1_media/files/media.png
2. Error messages and/or full log output:
2024/02/28 17:27:44.963 INFO using provided configuration {"config_file": "Caddyfile", "config_adapter": ""}
Error: adapting config using caddyfile: parsing caddyfile tokens for 'route': parsing caddyfile tokens for 'file_server': unknown subdirective 'uri', at Caddyfile:9, at Caddyfile:17
(I've removed the comments and global not related, w.r.t. TLS auths etc,.)
3. Caddy version:
2.7.6
4. How I installed and ran Caddy:
a. System environment:
Debian 11
.deb package
b. Command:
systemctl restart
c. Service/unit/compose file:
d. My complete Caddy config:
user1.site.info {
route {
file_server /static/* {
uri strip_prefix /static
root /home/user1web/static/user1_static/
}
file_server /media/* {
uri strip_prefix /media
root /home/user1web/static/user1_media/
}
reverse_proxy 127.0.0.1:9000
}
log {
format json
output file /var/log/caddy/caddy-user1.log {
roll_keep 30
roll_size 200M
}
level debug
}
}
5. Links to relevant resources:
Can’t see a place in the path other than after the file_server mather to do the uri strip of prefix