caddy-tailscale icon indicating copy to clipboard operation
caddy-tailscale copied to clipboard

allow port to be configured with direct assignment

Open chrishoage opened this issue 9 months ago • 0 comments
trafficstars

Closes: https://github.com/tailscale/caddy-tailscale/issues/84

Rational:

In some environments (like docker) it is desirable to expose the tailscale port to increase direct connection success. By default ts-net when encountering a 0 port will pick a port at random. This is difficult for docker since the ports are not known.

This work extends the node config to allow a node to gain a specific port, allowing for exposing in docker (or any other time where a user may wish to expose the port)

Steps to test:

  1. Check out branch and run xcaddy build --with github.com/tailscale/caddy-tailscale=$(pwd)

  2. Run the following caddyfile with TS_AUTHKEY in environment

{
  tailscale {
    ephemeral

    test-caddy {
      port 41650
    }
    other-caddy {
      port 41651
    }
    more-other-caddy {
      port 41652
    }
  }
}

:80 {
  bind tailscale/test-caddy
  respond OK
}
:80 {
  bind tailscale/other-caddy
  respond OK
}

:80 {
  bind tailscale/more-other-caddy
  respond OK
}

  1. Verify port and that caddy serves correctly

curl http://test-caddy

chrishoage avatar Feb 17 '25 01:02 chrishoage