TSDProxy Documentation

repository·main·Indexed 23 days ago

https://github.com/almeidapaulopt/tsdproxy

TSDProxy is a Tailscale Docker Proxy that exposes Docker containers on a Tailscale network using Docker labels. It eliminates the need for sidecar containers by centrally managing Tailscale machines and automatic HTTPS certificates via MagicDNS. It supports automatic container discovery, custom port mapping for HTTP, HTTPS, TCP, and UDP, and provides a real-time web dashboard for monitoring active proxies.

Tokens
79K
Snippets
258
Records
388
Agent score
81%

What's inside TSDProxy

  1. Overview of TSDProxy features and benefits

    main

    TSDProxy is an open-source application that automatically creates reverse proxies to virtual addresses in your Tailscale network. It simplifies traffic redirection to services running inside Docker containers using either Docker container labels or YAML proxy lists.

    Key benefits include:

    • No extra containers: You do not need a separate Tailscale container for every service you want to expose.
    • Label-driven configuration: You can configure proxies simply by adding Docker labels to your existing containers.
    • Automatic HTTPS: It leverages Tailscale's built-in Let's Encrypt certificate support via MagicDNS.
    • Multiple discovery methods: Supports both automatic Docker container discovery and manual YAML proxy list files.
    • Monitoring: Includes a real-time web dashboard with SSE (Server-Sent Events) streaming to monitor all active proxies.
  2. What is TSDProxy?

    main
    TSDProxy is a proxy application that automatically creates proxies to virtual addresses within your Tailscale network. It is designed to simplify traffic redirection to services running inside Docker containers. Instead of deploying a dedicated Tailscale container for every individual service, TSDProxy manages multiple services through a single instance using either Docker container labels or a proxy list file.
  3. Overview of TSDProxy

    main

    TSDProxy is a lightweight, open-source proxy designed to facilitate virtual services within a Tailscale network. It allows you to proxy traffic to virtual Tailscale addresses using Docker container labels, eliminating the need to run a dedicated Tailscale container for every individual service.

    Key capabilities include:

    • Automatic TLS Support: Automatically handles Tailscale/Let's Encrypt certificates via MagicDNS.
    • Simplified Configuration: Uses Docker container labels to route traffic, avoiding the need to manually configure virtual hosts in your Tailscale network.
    • Efficiency: Lightweight design that reduces resource overhead compared to per-service Tailscale instances.
  4. Key features and capabilities of TSDProxy

    main

    TSDProxy provides several advanced features for Tailscale-based proxying:

    • Multi-port per proxy: Each Tailscale machine can expose multiple ports with independent protocols.
    • TCP proxying: Supports raw TCP forwarding for SSH, databases, gRPC, and other non-HTTP protocols.
    • Tailscale Funnel support: Expose services to the public internet by adding the tailscale_funnel option to a port.
    • Dashboard: A real-time web UI for monitoring proxies, status, and authentication.
    • List provider: Allows proxying non-Docker services via a YAML configuration.
    • Dynamic lifecycle: Automatically reacts to container starts, stops, and removals in real time.
    • Live config reload: Configuration changes take effect without restarting the TSDProxy container.
  5. Key features of TSDProxy v3

    main

    TSDProxy v3 provides the following capabilities:

    • Easy to Use: Creates virtual Tailscale addresses using Docker container labels.
    • Really Easy to Use: Creates virtual Tailscale addresses using a proxy list.
    • Lightweight: Avoids the overhead of spinning up a dedicated Tailscale container for every service.
    • Quick deploy: Removes the need to manually configure virtual hosts in your Tailscale network.
    • Automatically supports TLS: Automatically handles Tailscale/Let's Encrypt certificates when using MagicDNS.
  6. Deployment options for TSDProxy

    main

    TSDProxy can be deployed using two primary methods depending on your infrastructure requirements:

    1. Standalone Binary: Run TSDProxy directly on the host machine without using Docker. This is suitable for simple setups or environments where container orchestration is not desired.
    2. Docker Swarm: Deploy TSDProxy across a Swarm cluster. This method utilizes service labels to manage deployment and configuration across multiple nodes.
  7. Understand Slack message format

    main

    TSDProxy sends messages to Slack using Slack's Block Kit format.

    Fallback text: TSDProxy: Proxy 'myapp' status changed to Running

    Block content structure:

    *TSDProxy Status Update*
    Proxy: `myapp`
    Status: `Running`
    Previous: `Starting`

    Note on @mentions: If a proxy name contains an @ character, TSDProxy automatically inserts a zero-width space to prevent the proxy name from triggering accidental user mentions in Slack.

  8. How TCP and UDP proxying works in TSDProxy

    main

    TSDProxy can proxy raw TCP and UDP connections through your Tailscale network. This allows you to expose services like SSH, databases (PostgreSQL, MySQL, Redis), gRPC, or game servers without HTTP overhead.

    Key Characteristics:

    • No HTTP Parsing/TLS Termination: For TCP/UDP, TSDProxy forwards raw bytes bidirectionally. The target service is responsible for its own encryption (e.g., SSH handles its own key exchange).
    • Tailnet Only: TCP ports are only accessible within your Tailscale network; Tailscale Funnel does not support raw TCP listeners.
    • Docker Networking: When proxying to containers, TSDProxy connects directly to the container IP. For this to work, the TSDProxy container and the target container must share the same Docker network.
  9. How backend health monitoring and auto-recovery work

    main

    TSDProxy features per-proxy backend health monitoring that allows it to recover from container restarts without requiring a proxy restart or Tailscale teardown. When a backend container restarts and receives a new IP address, TSDProxy detects the failure and automatically re-resolves the target.

    The Recovery Lifecycle

    1. Health Probes: TSDProxy probes the proxy's first non-redirect port at a configurable interval.
      • HTTP/HTTPS: Uses a GET request.
      • TCP: Uses a connection attempt.
      • UDP: Uses a probe packet.
    2. Failure Threshold: Once consecutive failures reach the configured limit (default: 3), TSDProxy triggers a target re-resolution.
    3. Hot-swap: If the new target address differs from the current one, it is swapped in place. Existing connections continue on the old target, while new connections immediately use the updated address.
    4. Backoff: After a re-resolution attempt, TSDProxy uses either exponential backoff or a fixed cooldown before the next attempt. A successful health check resets all counters and backoff timers immediately.
  10. Understand the health check backoff strategy

    main

    TSDProxy uses two modes for timing re-resolution attempts after a failure:

    1. Exponential Backoff (Default)

    When healthCheckCooldown is set to 0, TSDProxy uses exponential backoff. With default settings (30s interval, 3 failures), the timeline looks like this:

    • 1st attempt: ~90s after initial failure (3 × 30s consecutive failures)
    • 2nd attempt: 30s delay
    • 3rd attempt: 60s delay
    • 4th attempt: 2min delay
    • 5th attempt: 4min delay
    • 6th+ attempt: 8min, 16min, etc., capped at 24h.

    2. Fixed Cooldown

    If you set a specific value for healthCheckCooldown (e.g., 120), TSDProxy will attempt re-resolution every 120 seconds as long as the target remains unhealthy, bypassing the exponential backoff logic.