This Docker-based application automatically creates a proxy to virtual addresses in your Tailscale network based on Docker container labels. It simplifies traffic redirection to services running inside Docker containers, without the need for a separate Tailscale container for each service.
https://almeidapaulopt.github.io/tsdproxy/
Before using this application, make sure you have:
This application scans running Docker containers for specific labels to configure proxies to Tailscale virtual addresses.
Add the following labels to the Docker containers you wish to proxy:
labels:
- "tsdproxy.enable=true"
- "tsdproxy.name=example"
- "tsdproxy.container_port=80"
tsdproxy.enable
: Set to true
to indicate that this container should be proxied.tsdproxy.name
: The name of the virtual Tailscale hostname that will be the proxy. You only need to set the subdomain, TsDProxy will automatically append the Tailscale domain (example: my-network.ts.net).tsdproxy.container_port
: The port on the container. (Container first exposed port by default)To run the TsDProxy itself, use the following Docker command:
docker run -d --name tsdproxy -v /var/run/docker.sock:/var/run/docker.sock almeidapaulopt/tsdproxy:latest
-v /var/run/docker.sock:/var/run/docker.sock
: This gives the proxy app access to the Docker daemon so it can monitor and interact with your containers.Here’s an example of how you can configure your services using Docker Compose:
TsDProxy docker-compose.yaml
services:
tailscale-docker-proxy:
image: almeidapaulopt/tsdproxy:latest
container_name: tailscale-docker-proxy
ports:
- "80:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- datadir:/data
restart: unless-stopped
environment:
- TSDPROXY_AUTHKEY=tskey-auth-SecretKey
- TSDPROXY_HOSTNAME=server1 # Address of docker server (access to example.com ports)
- DOCKER_HOST=unix:///var/run/docker.sock
#- TSDPROXY_AUTHKEYFILE=/run/secrets/authkey # to use docker secrets, Don't use AUTHKEY
#- TSDPROXY_DATADIR:/data # defaults to /data
#- TSDPROXY_LOGLEVEL=info
#- TSDPROXY_CONTAINERACCESSLOG=true #enable proxy access log for all active containers
#secrets:
#- authkey
#secrets:
# authkey:
#file: tsdproxy_authkey.txt
volumes:
datadir:
YourService docker-compose.yaml
services:
my-service:
image: my-service-image
labels:
- "tsdproxy.enable=true"
ports:
- "8080:8080"
tsdproxy.enable=true
to create a proxy.This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to open issues or submit pull requests to help improve the app.