You need to proxy to the port the service uses inside the docker network, not the one you bound to the host machine.
Remove these lines, you don’t need to bind this server’s ports to the host if you’re proxying to it with Caddy.
Then in Caddy, do reverse_proxy file:80
(since your container is named file
, and it seems to listen on port 80).
Please make sure you persist /data
, otherwise you’ll lose Caddy’s certs and keys every time you tear down and restart the container, which can make you hit rate limits, and it’s just wasteful in general.
Remove these global options, they’re redundant. Those are already the default HTTP and HTTPS ports.
You can use handle_path
instead, which will do the strip_prefix
logic for you implicitly.
handle_path /filegator/* {
reverse_proxy file:80
}
But keep in mind, when proxying a subpath to an upstream app, you can run into trouble if the upstream app isn’t configured to know that it’s supposed to run under a particular path. This article explains:
Also, I’d suggest to wrap your other part, your PHP app, in a handle
so that it’s properly mutually exclusive with your proxy. So altogether:
localhost {
handle_errors {
respond "{http.error.status_code} {http.error.status_text}"
}
encode gzip
redir /filegator /filegator/ permanent
handle_path /filegator/* {
reverse_proxy file:80
}
handle {
root * /app/public/
php_fastcgi php:9000
file_server
}
}