Docker Alpine Tailscale Caddy - Tailscale-Caddy proxy
1.2K
A Docker image that seamlessly enables sharing of HTTP services over the Tailscale network with automatic HTTPS support. This solution combines the power of Tailscale's secure networking with Caddy's automated certificate management to provide a robust, maintenance-free way to expose web services to authorized users.
In today's containerized environments, sharing web services securely often involves complex configuration of firewalls, authentication systems, and SSL certificates. This project simplifies that process by leveraging Tailscale's secure networking capabilities and Caddy's automatic HTTPS features.
The Tailscale-Caddy proxy provides several advantages over alternative solutions:
The proxy container runs two main components:
When started, the container:
Before using this proxy, ensure you have:
TS_HOSTNAME: The device name in your Tailscale network
Example: myapp-proxy
TS_TAILNET: Your tailnet name (without the .ts.net suffix)
Example: mycompany
CADDY_TARGET: The service endpoint to proxy to
Example: webapp:8080
TS_EXTRA_ARGS: Additional arguments for the Tailscale daemon
Example: --advertise-exit-node --hostname=custom-name/var/lib/tailscale: Stores Tailscale credentials (required for persistence)This example shows how to expose a simple web application:
version: '3'
networks:
app_network:
external: false
volumes:
tailscale_state:
services:
webapp:
image: nginx
volumes:
- ./website:/usr/share/nginx/html
networks:
- app_network
tailscale_proxy:
image: hhftechnology/alpine-tailscale-caddy:latest
volumes:
- tailscale_state:/var/lib/tailscale
environment:
- TS_HOSTNAME=webapp-proxy
- TS_TAILNET=mycompany
- CADDY_TARGET=webapp:80
networks:
- app_network
restart: always
init: true
You can run multiple instances of the proxy to expose different services:
version: '3'
networks:
internal_network:
external: false
volumes:
ts_state_app1:
ts_state_app2:
services:
app1:
image: ghost:latest
networks:
- internal_network
app2:
image: wordpress:latest
networks:
- internal_network
ts_proxy_app1:
image: hhftechnology/alpine-tailscale-caddy:latest
volumes:
- ts_state_app1:/var/lib/tailscale
environment:
- TS_HOSTNAME=blog-proxy
- TS_TAILNET=mycompany
- CADDY_TARGET=app1:2368
networks:
- internal_network
ts_proxy_app2:
image: hhftechnology/alpine-tailscale-caddy:latest
volumes:
- ts_state_app2:/var/lib/tailscale
environment:
- TS_HOSTNAME=wordpress-proxy
- TS_TAILNET=mycompany
- CADDY_TARGET=app2:80
networks:
- internal_network
Perfect for local development with multiple services:
version: '3'
networks:
dev_network:
external: false
volumes:
ts_dev_state:
services:
frontend:
image: node:latest
command: npm run dev
volumes:
- ./frontend:/app
networks:
- dev_network
backend:
image: python:3.9
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./backend:/app
networks:
- dev_network
ts_proxy:
image: hhftechnology/alpine-tailscale-caddy:latest
volumes:
- ts_dev_state:/var/lib/tailscale
environment:
- TS_HOSTNAME=dev-environment
- TS_TAILNET=mycompany
- CADDY_TARGET=frontend:3000
networks:
- dev_network
docker-compose up
docker-compose up -d
After setup, your services will be available at:
https://[TS_HOSTNAME].[TS_TAILNET].ts.nethttp://[TS_HOSTNAME].[TS_TAILNET].ts.net (automatically redirects to HTTPS)For example:
https://webapp-proxy.mycompany.ts.netCommon issues and solutions:
Certificate errors:
docker-compose logs ts_proxyConnection issues:
Authentication problems:
The Tailscale-Caddy proxy provides several security benefits:
You can pass additional arguments to Tailscale using TS_EXTRA_ARGS:
environment:
- TS_EXTRA_ARGS=--hostname=custom-name --advertise-exit-node --advertise-tags=tag:web
Create separate networks for different service groups:
networks:
frontend_net:
internal: true
backend_net:
internal: true
Contributions are welcome! Please:
This project is licensed under the MIT License - see the LICENSE file for details.
Content type
Image
Digest
sha256:9d2260ab8…
Size
78.7 MB
Last updated
over 1 year ago
docker pull hhftechnology/alpine-tailscale-caddy