Zero Trust Tailscale/Headscale: Secure Admin Panels & Databases
Implement Zero Trust mesh network via Tailscale/Headscale to protect admin panels and staging databases. Covers configuration, ACL management, and security best practices on...
In the modern cloud computing landscape, protecting internal resources such as admin panels, management systems, and staging databases from unauthorized access is paramount. Traditional perimeter-based firewall security is no longer sufficient against increasingly sophisticated threats. Instead, the Zero Trust architecture has emerged as the new standard, where every access request must be verified, regardless of whether it originates from inside or outside the network.
This article will guide you through deploying a robust Zero Trust mesh network using either Tailscale or Headscale to secure access to your Admin Panels and staging databases on DPTCloud's Cloud VPS infrastructure. We will delve into configuration, management, and best practices to ensure maximum security.
Tailscale vs. Headscale: Choosing Your Control Plane
Both Tailscale and Headscale are solutions for deploying WireGuard-based mesh VPNs, offering effortless Zero Trust connectivity. The key difference lies in the Control Plane:
- Tailscale: Utilizes a Control Plane managed by Tailscale Inc. This is the simplest option, requiring no self-management of the Control Plane infrastructure. It's suitable for teams seeking convenience and rapid scalability.
- Headscale: An open-source implementation of a Tailscale-compatible Control Plane. You self-host and manage your Headscale server. This provides full control over your data, policies, and integration with existing authentication systems (e.g., OpenID Connect, SAML). Headscale is ideal for organizations with strict compliance requirements or those desiring deep customization.
With Cloud VPS infrastructure at CMC Telecom and FPT Telecom (Saigon Hi-Tech Park / Khu CNC Quận 9, Ho Chi Minh City), DPTCloud provides an ideal environment for deploying Headscale, ensuring high performance and reliability.
Deploying Headscale on a DPTCloud VPS
For full control, we will deploy Headscale on a DPTCloud Cloud VPS.
1. Environment Preparation
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl gnupg lsb-release
Install Docker and Docker Compose (if not already present):
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
newgrp docker # Apply group changes immediately
sudo apt install -y docker-compose
2. Headscale Configuration with Docker Compose
Create a project directory and the docker-compose.yml file:
mkdir headscale && cd headscale
nano docker-compose.yml
docker-compose.yml content:
version: '3.8'
services:
headscale:
image: headscale/headscale:latest
container_name: headscale
restart: unless-stopped
ports:
- "8080:8080" # Web interface and API
- "9090:9090" # gRPC port (optional)
volumes:
- ./config:/etc/headscale
- ./data:/var/lib/headscale
command: headscale serve
cap_add:
- NET_ADMIN # Required for WireGuard
environment:
- HEADSCALE_SERVER_URL=http://your_vps_ip:8080 # Replace with your VPS IP or domain
- HEADSCALE_LISTEN_ADDR=0.0.0.0:8080
- HEADSCALE_GRPC_LISTEN_ADDR=0.0.0.0:9090
- HEADSCALE_METRICS_LISTEN_ADDR=0.0.0.0:9091
- HEADSCALE_DB_PATH=/var/lib/headscale/db.sqlite
- HEADSCALE_LOG_LEVEL=info
Create the Headscale configuration file in the ./config directory:
mkdir config
nano config/config.yaml
Minimal config/config.yaml content:
server_url: http://your_vps_ip:8080 # Replace with your VPS IP or domain
listen_addr: 0.0.0.0:8080
grpc_listen_addr: 0.0.0.0:9090
metrics_listen_addr: 0.0.0.0:9091
db_path: /var/lib/headscale/db.sqlite
unix_socket: /var/run/headscale/headscale.sock
private_key_path: /etc/headscale/private.key
noise_private_key_path: /etc/headscale/noise_private.key
log_level: info
dns_config:
override_local_dns: true
nameservers:
- 8.8.8.8
- 8.8.4.4
magic_dns: true
base_domain: headscale.net # Domain for Magic DNS
Start Headscale:
docker-compose up -d
3. User and Node Management
Create the first user:
docker exec headscale headscale users create admin
On your client machine (e.g., your computer), install the Tailscale client and connect to the Headscale server:
tailscale up --login-server http://your_vps_ip:8080
After running this command, you'll receive a URL for authentication. Paste that URL into your browser, log in with the Headscale user account you created, and your node will appear in the network.
Check connected nodes:
docker exec headscale headscale nodes list
Integrating Admin Panels and Databases
Once the mesh network is established, you can easily access internal resources.
1. Securing Admin Panels (e.g., pgAdmin, phpMyAdmin)
Instead of exposing Admin Panels to the public Internet, you can restrict access to only through the Tailnet. Assuming pgAdmin runs on another VPS within the Tailnet with IP 100.x.x.x:
# On the VPS running pgAdmin
sudo ufw allow from 100.0.0.0/8 to any port 80/443 # or pgAdmin's port
Then, from your computer (connected to Tailscale), you can access pgAdmin using its Tailnet IP (e.g., http://100.x.x.x:80).
2. Protecting Staging Databases (PostgreSQL, MySQL)
Similarly, staging databases should not have public access. Modify firewall and database configurations to listen only on the Tailnet IP.
PostgreSQL
Edit postgresql.conf and pg_hba.conf. In postgresql.conf, change listen_addresses:
listen_addresses = 'localhost,100.x.x.x' # Add your VPS's Tailnet IP
In pg_hba.conf, add a line to allow access from the Tailnet:
host all all 100.0.0.0/8 md5
Restart PostgreSQL:
sudo systemctl restart postgresql
MySQL/MariaDB
Edit my.cnf or mariadb.conf.d/50-server.cnf. Change bind-address:
bind-address = 100.x.x.x # Your VPS's Tailnet IP
Then, create a user that allows access from any Tailnet IP:
CREATE USER 'your_user'@'100.%.%.%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON your_database.* TO 'your_user'@'100.%.%.%';
FLUSH PRIVILEGES;
Restart MySQL/MariaDB:
sudo systemctl restart mysql
Security Best Practices and Advanced Configuration
To enhance the security of your Tailnet:
1. Utilize Access Control Lists (ACLs)
ACLs are the backbone of Zero Trust. With Headscale, you define access policies in a policy.yaml file:
# policy.yaml
acls:
- action: accept
src: ["tag:admin"]
dst: ["tag:webserver:80", "tag:database:5432"]
groups:
admin:
- user:admin
tagOwners:
tag:admin:
- user:admin
tag:webserver:
- user:admin
tag:database:
- user:admin
After updating, push the ACL to Headscale:
docker exec headscale headscale set-policy /etc/headscale/policy.yaml
2. Exit Nodes
Configuring an Exit Node allows devices in your Tailnet to route all their internet traffic through a specific node. This is useful for accessing geo-restricted resources or masking your real IP address.
# On the VPS you want to be the Exit Node
tailscale up --advertise-exit-node
Then, approve the Exit Node on Headscale:
docker exec headscale headscale nodes list # Get the Exit Node's ID
docker exec headscale headscale nodes update --exit-node <node_id> --enable-exit-node
On the client machine, you can use the Exit Node with the command:
tailscale up --exit-node <exit_node_ip_or_hostname>
3. SSO/OIDC Integration
Headscale supports integration with OpenID Connect (OIDC) providers like Google, GitHub, or Keycloak. This allows you to leverage existing identities for user authentication into your Tailnet, enhancing security and convenience.
| Criterion | Tailscale (Managed) | Headscale (Self-hosted) |
|---|---|---|
| Control Plane Management | Tailscale Inc. | Self-hosted by you |
| Customization | Limited | Full control |
| Cost | Subscription-based | VPS hosting cost |
| Complexity | Low | Medium |
| Compliance | Relies on Tailscale | Fully your responsibility |
Note: Always ensure your Headscale server is regularly updated and protected by a firewall (e.g., UFW) to allow access only to necessary ports (8080 for API/web, 9090 for gRPC if used).
Conclusion
Establishing a Zero Trust network with Tailscale or Headscale is a critical step towards securing your infrastructure in 2026. By eliminating the concept of a 'trusted network,' you reduce the attack surface and ensure that only authorized users and devices can access sensitive resources like Admin Panels and staging databases.
With DPTCloud's high-performance Cloud VPS, hosted in leading Tier III data centers like CMC Telecom and FPT Telecom in Saigon Hi-Tech Park / Khu CNC Quận 9, Ho Chi Minh City, you have a solid foundation to deploy a reliable Headscale server. DPTCloud provides NVMe Enterprise RAID 10 servers and 10Gbps uplinks, ensuring optimal performance for your Zero Trust network.
Ready to deploy on PCIe Gen4 NVMe VPS & 10Gbps Uplinks?
Provision servers in under 60 seconds with edge Anti-DDoS protection and 99.99% SLA uptime.
