• 0 Posts
  • 3 Comments
Joined 1 year ago
cake
Cake day: December 14th, 2023

help-circle
  • Partially yes, the tricky thing is that when using network_mode: "service:tailscale" (presumably on the caddy container since that’s what needs to receive traffic from the tailscale network), you won’t be able to attach the caddy container to any networks since it’s using the tailscale network stack. This means that in order for caddy to reach your containers, you will need to add the tailscale container itself to the relevant networks. Any attached containers will be connected as well.

    (Not sure if I misread the first time or if you edited but the way you say it is right, add the tailscale container to the proxy network so that caddy will also be added and can reach the containers)

    Here’s the super condensed version of what matters for connecting traefik/caddy to a VPN like wireguard/tailscale.

    • I left out all WG config since presumably you know how to configure tailscale
    • Left out acme / letsencrypt stuff since that would be different on caddy anyway
    • You may need to configure caddy to trust the tailscale tunnel IP of the machine on the other end that will be reverse proxying over the tunnel.
    • Traefik I guess requires you to specify the docker network to use to reach stuff, I just put anything that should be accessible into “ingress” as you can see. I’m not sure if my setup supports using a different proxy network per app but maybe caddy allows that.

    My traefik compose:

    services:
      wireguard:
        container_name: wireguard
        networks:
          - ingress
    
      traefik:
        network_mode: "service:wireguard"
        depends_on:
          - wireguard
        command:
          - "--entryPoints.web.proxyProtocol.trustedIPs=10.13.13.1" # Trust remote tunnel IP, the WG container is 10.13.13.2
          - "--entrypoints.websecure.address=:443"
          - "--entryPoints.websecure.proxyProtocol.trustedIPs=10.13.13.1"
          - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
          - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
          - "--entrypoints.web.http.redirections.entrypoint.priority=100"
          - "--providers.docker.exposedByDefault=false"
          - "--providers.docker.network=ingress"
    
    networks:
      ingress:
        external: true
    
    

    And then in a service’s docker-compose:

    services:
      ui:
        image: myapp
        read_only: true
        restart: always
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.myapp.rule=Host(`xxxx.xxxx.xxxx`)"
          - "traefik.http.services.myapp.loadbalancer.server.port=80"
          - "traefik.http.routers.myapp.entrypoints=websecure"
          - "traefik.http.routers.myapp.tls.certresolver=mytlschallenge"
        networks:
          - ingress
    
    networks:
      ingress:
        external: true
    
    

    (edited to fix formatting on mobile)


  • I’ve done something similar but I’m not sure how helpful my example would be because I use wireguard instead of tailscale and traefik instead of caddy.

    The principle is the same though, iirc I have my traefik container set to network_mode: “service:wireguard” so that the traefik container uses the wireguard container’s network stack. That way the traefik container also sees the wireguard interface and can receive traffic going to the wireguard IP. Then at the other end of the wireguard tunnel I can use haproxy to pass traffic to the wireguard IP through the tunnel and it automatically hits traefik.


  • You could do something like that using point-to-point wireless links or just cables slung between buildings to connect boxes running a self-organizing mesh network protocol like yggdrasil. But there are too many challenges for me to go into depth here ranging from getting buy in from enough people who are located in close proximity, managing user expectations of speed, making services available over such an overlay network (or managing and paying for proxies that provide access to the regular Internet), dealing with geography, etc.

    You’d basically be looking at replicating freifunk or nycmesh or doing something along those lines. NYCmesh as I can tell operates more like an ISP so I would expect it to be at least harder than what they do.

    Imo time is better invested in developing and advancing decentralized applications and protocols, such as developing stuff using bittorrent/DHT or I2P which can just take advantage of the existing internet.