1. The problem I’m having:
I am currently attempting to migrate from nginx to Caddy, and I’m trying to migrate a personal Pacman package proxy cache along with my other stuff. A similar config to what I had can be found here.
Unfortunately, however, I can’t seem to find a Caddy equivalent to nginx’s proxy_store directive. This is the part that effectively makes the whole thing work; it saves every archive file it receives from the reverse proxy upstream to a local directory preserving the original name/location, and it returns the local copy on every subsequent request to avoid downloading from upstream every time.
Is there a way I can replicate this setup, with or without plugins? I noticed the existence of GitHub - caddyserver/cache-handler: Distributed HTTP caching module for Caddy · GitHub, but it didn’t seem to be able to cache to a regular file.
2. Error messages and/or full log output:
N/A
3. Caddy version:
v2.11.2
4. How I installed and ran Caddy:
a. System environment:
Quadlet (Podman) on Fedora 43 (x86_64) (an external machine on the local network)
b. Command:
# systemctl start caddy
c. Service/unit/compose file:
[Unit]
Description=Caddy reverse proxy
After=network-online.target nss-lookup.target
Wants=network-online.target
[Container]
Image=docker.io/caddy:alpine
AutoUpdate=registry
ContainerName=caddy
PublishPort=80:80
PublishPort=443:443
PublishPort=443:443/udp
Network=podman
ReloadCmd=caddy reload --config /etc/caddy/Caddyfile
Volume=/etc/caddy:/etc/caddy:z
Volume=/var/containers/caddy/config:/config:z
Volume=/var/containers/caddy/data:/data:z
Volume=/var/log/caddy:/var/log/caddy:z
Volume=/var/www:/var/www:z
NoNewPrivileges=true
DropCapability=ALL
AddCapability=NET_ADMIN NET_BIND_SERVICE
Memory=1g
PodmanArgs=--memory-reservation=512m --cpu-shares=1024
[Service]
Restart=always
RestartSec=5s
[Install]
WantedBy=default.target
d. My complete Caddy config:
Admittedly untested, as the described issue is a blocker:
(repo) {
reverse_proxy {
dynamic a geo.mirror.pkgbuild.com 443 {
versions ipv6
}
# todo: figure out how to cache response to /var/www/paccache
# with the same directory layout, and preferably toggle
# based on a snippet arg
transport http {
tls
}
}
}
http:// {
root /var/www/paccache
@db path_regexp \.(db|sig|files)$
@tar path_regexp \.tar\.(xz|zst)$
handle @db {
# always proxy db/sig files, never cache
import repo
}
handle {
file_server browse
}
handle_errors {
handle @tar {
# the intent here is to search for local .tar files first,
# and then proxy/cache from upstream if none are found
import repo store
}
}
}