Overview
Running services on your Tailscale network provides significant security benefits over traditional port forwarding, but proper configuration is essential. This guide covers security best practices for ScaleTail deployments.Fundamental Security Principles
Defense in Depth
Use multiple security layers - Tailscale ACLs, container isolation, application authentication, and system hardening.
Least Privilege
Grant only the minimum access required. Restrict ACLs, limit container capabilities, and use read-only volumes where possible.
Secrets Management
Never commit secrets to version control. Use environment variables and secure storage.
Regular Updates
Keep Tailscale, Docker, and application images updated to patch security vulnerabilities.
Authentication and Authorization
Tailscale Auth Keys
Use ephemeral auth keys for temporary deployments:TS_AUTH_ONCE Configuration
TheTS_AUTH_ONCE=true setting prevents repeated authentication:
- Container only authenticates on first start
- Prevents auth key reuse if container is compromised
- State persisted in volume survives container restarts
Access Control Lists (ACLs)
Restrict Service Access
Use Tailscale ACLs to control who can access which services:Service-Specific Tags
Apply tags to services usingTS_EXTRA_ARGS:
Port-Level Restrictions
Limit access to specific ports:Container Security
Minimize Capabilities
Tailscale requiresnet_admin, but avoid adding unnecessary capabilities:
Read-Only Volumes
Use read-only mounts where data doesn’t need to change:User Permissions (PUID/PGID)
Run containers as non-root users:Resource Limits
Prevent resource exhaustion attacks:Network Security
Network Mode Considerations
Sidecar pattern (recommended for most services):- Application only accessible via Tailscale
- No direct host network exposure
- Simple to configure
Port Exposure
Default: No port exposureCONTRIBUTING.md:
Keep the ports section commented unless LAN exposure is required; explain why in the README if you expose anything.
Firewall Configuration
Even with Tailscale, maintain host firewall rules:Exit Node Security
Restrict Exit Node Usage
From the exit node documentation, configure ACLs to limit who can use exit nodes:Exit Node Sysctls
The exit node configuration requires IP forwarding:DNS Security with Exit Nodes
Prevent DNS leaks by forcing DNS through Tailscale:Secrets Management
Environment Variables
Store secrets in.env files:
.gitignore:
.env.example with placeholders:
Docker Secrets (Swarm)
For Docker Swarm deployments, use Docker secrets:Volume Permissions
Protect sensitive volumes:Image Security
Use Official Images
Prefer official images from trusted sources:Pin Image Versions
For production, pin specific versions:Scan Images for Vulnerabilities
Regular Updates
Update images regularly:Health Checks and Monitoring
Tailscale Health Check
The template includes a Tailscale health check:Application Health Checks
Implement application-specific health checks:Log Monitoring
Monitor for suspicious activity:MagicDNS Security
DNS Configuration
From the MagicDNS documentation:- DNS queries route through Tailscale
- Prevents DNS leaks when using exit nodes
- Enables split DNS for internal services
- You need specific public DNS servers
- DNS routing conflicts with your setup
- Testing connectivity issues
Split DNS Security
Use split DNS to isolate internal domains:- Internal domains only resolve on Tailscale network
- External domains use public DNS
- Prevents information leakage
Incident Response
Disable Compromised Keys
- Go to Tailscale admin console
- Revoke the compromised auth key
- Generate a new key
- Update
.envand redeploy:
Remove Compromised Device
- Navigate to Machines
- Find the compromised device
- Click “Remove device”
- Review ACL logs for unauthorized access
Audit Access Logs
Review Tailscale network logs:- Go to Network activity
- Filter by date/device
- Look for unexpected connections
- Update ACLs to prevent future unauthorized access
Container Forensics
If a container is compromised:Compliance Considerations
Data Residency
Ensure services comply with data residency requirements:- Deploy services in appropriate geographic regions
- Use exit nodes to control apparent location
- Document data flow in your README
Audit Trails
Maintain audit logs:Encryption at Rest
Encrypt sensitive volumes:Security Checklist
Before deploying a service, verify:- Secrets stored in
.env, not committed to git -
.envadded to.gitignore - ACLs configured to restrict access
- Tags applied to service (
TS_EXTRA_ARGS) -
TS_AUTH_ONCE=trueenabled - Ephemeral or tagged auth key used
- Ports commented unless LAN access required
- Health checks configured for both containers
- Volume permissions set correctly
-
PUID/PGIDmatch non-root user - Read-only volumes where applicable
- Resource limits configured
- Official or trusted images used
- Image versions pinned for production
- Exit node ACLs restrict usage (if applicable)
- DNS configuration appropriate for use case
- Documentation includes security notes
Related Resources
Exit Nodes
Secure exit node configuration
MagicDNS
DNS security with MagicDNS
Custom Services
Secure custom service creation