• 0 Posts
  • 30 Comments
Joined 6 months ago
cake
Cake day: January 2nd, 2024

help-circle










  • Here’s the secret to stuff like this:

    Run a single reverse proxy / edge router for all of your containerised services.

    I recommend Traefik - https://gitlab.com/Matt.Jolly/traefik-grafana-prometheus-docker

    You can configure services with labels attached to the container and (almost) never expose ports directly. It also lets you host an arbitrary number of services listening on 80/443.

    An example config might look like this:

    # docker-compose.yml
    version: '3.9'
    
    services:
      bitwarden:
        image: vaultwarden/server:latest
        restart: always
        volumes:
          - /data/vaultwarden/:/data
        environment:
    #      - ADMIN_TOKEN=
          - WEBSOCKET_ENABLED=true
        networks:
          - proxy
        labels:
          - traefik.enable=true
          - traefik.http.routers.bitwarden-ui-https.tls.certresolver=letsencrypt
          - traefik.http.middlewares.redirect-https.redirectScheme.scheme=https
          - traefik.http.middlewares.redirect-https.redirectScheme.permanent=true
          - traefik.http.routers.bitwarden-ui-https.rule=Host(`my.domain.com`)
          - traefik.http.routers.bitwarden-ui-https.entrypoints=websecure
          - traefik.http.routers.bitwarden-ui-https.tls=true
          - traefik.http.routers.bitwarden-ui-https.service=bitwarden-ui
          - traefik.http.routers.bitwarden-ui-http.rule=Host(`my.domain.com`)
          - traefik.http.routers.bitwarden-ui-http.entrypoints=web
          - traefik.http.routers.bitwarden-ui-http.middlewares=redirect-https
          - traefik.http.routers.bitwarden-ui-http.service=bitwarden-ui
          - traefik.http.services.bitwarden-ui.loadbalancer.server.port=80
          - traefik.http.routers.bitwarden-websocket-https.rule=Host(`my.domain.com) && Path(`/notifications/hub`)
          - traefik.http.routers.bitwarden-websocket-https.entrypoints=websecure
          - traefik.http.routers.bitwarden-websocket-https.tls=true
          - traefik.http.routers.bitwarden-websocket-https.service=bitwarden-websocket
          - traefik.http.routers.bitwarden-websocket-http.rule=Host(`my.domain.com`) && Path(`/notifications/hub`)
          - traefik.http.routers.bitwarden-websocket-http.entrypoints=web
          - traefik.http.routers.bitwarden-websocket-http.middlewares=redirect-https
          - traefik.http.routers.bitwarden-websocket-http.service=bitwarden-websocket
          - traefik.http.services.bitwarden-websocket.loadbalancer.server.port=3012
    








  • You’re on the right track. I’m on mobile so will be brief, edit from a laptop in a while.

    You can use subdomains, which is my preferred way if making services work with traefik, but you could also look for, say, example.com/potato to get to the potato service; this may work better with DDNS.

    Edit: each subdomain needs to be updated, you might be able to get away with making them all a CNAME that points at the DDNS.

    You’re correct in your assessment that you only expose 80 and 443 for the Traefik container and access everything else through that. Also only use 80 to redirect to 443.

    Don’t expose the NAS directly to the web, instrad look at port forwarding on your router, it should be able to forward requests received on only 80 and 443 to the NAS while still blocking everything else.

    My only complaint about Synology stuff is that I couldn’t get Traefik in swarm mode going!

    Any questions reach out.

    Edit2: consider looking at a cheap VPS or a static IP to eliminate the requirement to expose your NAS directly to the web. Alternately run your internal DNS for stuff (including SSL certs from LetsEncrypt) and VPN in (I use Wireguard) when you want to access it.


  • Close enough to 0 downtime that it doesn’t matter.

    1. Deploy updated stack file to existing stack
    2. existing services are updated
    3. Traefik polls the docker socket and notices updated labels
    4. ???
    5. Profit!

    Seriously, you shouldn’t need to put anything (outside of rules that you want to re-use [e.g. http->https middleware]) in the traefik dynamic configuration because each container/service in a docker stack will bring with it its own configuration. Your only ‘dead time’ is how long it takes Traefik to pick up the new dynamic configuration via either the docker or swarm providers, which is configurable but I’ve never had to touch because, even on production systems, it’s been fine.