Closed stefandesu closed 7 months ago
https://github.com/nginx-proxy/nginx-proxy/discussions/1962#discussioncomment-2578261
example.com
file:location /static {
root /www/data;
}
/etc/nginx/vhost.d/example.com
/www/data/static/
Note that this only works for subfolders that are NOT convered by other services. As soon as there is an overlap, only the static content will be served. Not sure if this is easily fixable...
An alternative that DOES involve more Docker containers, but is more flexible too, would be to use a very small http server (like this one) with the usual VIRTUAL_PATH
configuration. This would allow us to override subpaths for existing services. This is probably the better option as it is easier to configure and to keep track of.
Edit: We can also use the busybox image directly (it's still very small and official):
version: "3"
services:
static-test:
image: busybox
volumes:
- $CONFIGS/static:/var/www/
environment:
- VIRTUAL_HOST=example.com
- VIRTUAL_PATH=/test/
- VIRTUAL_DEST=/
command: httpd -f -h /var/www/
restart: unless-stopped
networks:
default:
external: true
name: nginx
I wonder if we can add an easy way to serve static files that doesn't involve even more Docker containers. There might be some way to do this directly with nginx-proxy.