gbv / coli-conc-server

Home folder, setup, and configuration for the server hosting public coli-conc software.
0 stars 1 forks source link

Easy way to serve static content #2

Closed stefandesu closed 7 months ago

stefandesu commented 8 months ago

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.

stefandesu commented 8 months ago

https://github.com/nginx-proxy/nginx-proxy/discussions/1962#discussioncomment-2578261

location /static {
    root /www/data;
}

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...

stefandesu commented 8 months ago

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