NewCode CLOUD — 20% off your first month on all cloud VPSClaim

Headscale on Hong Kong VPS: Self-Hosted Tailscale Mesh VPN (2026)

· 4 min read

Tailscale uses WireGuard to create a zero-config mesh VPN — every device gets a direct encrypted tunnel to every other device, no central server routing required. Headscale is the open-source, self-hosted Tailscale coordination server. Running Headscale on a Hong Kong VPS means your coordination server is close to your Asia-Pacific team, keeps all device metadata on your own infrastructure, and eliminates Tailscale’s per-seat fees for larger teams.


How Headscale/Tailscale Mesh Works

<code">
HK VPS (Headscale coordination server)
          │
    ┌─────┴──────────────────────┐
    │ Registers devices          │
    │ Distributes public keys    │
    │ Manages IP assignments     │
    └─────┬──────────────────────┘
          │ (coordination only — no traffic routing)
    ┌─────┼──────────────────────────────┐
    │     │                              │
Developer  Singapore VPS        Office (Beijing)
Laptop     (Production)         Desktop
10.64.0.1  10.64.0.2           10.64.0.3
    │          │                   │
    └──────────┴───────────────────┘
         Direct WireGuard tunnels
         (P2P, HK VPS not in data path)

Step 1: Install Headscale

<code">HEADSCALE_VERSION=$(curl -s https://api.github.com/repos/juanfont/headscale/releases/latest \
  | grep tag_name | cut -d '"' -f4)

wget "https://github.com/juanfont/headscale/releases/download/${HEADSCALE_VERSION}/headscale_linux_amd64.deb"
dpkg -i headscale_linux_amd64.deb

# Verify
headscale version

Step 2: Configure Headscale

<code"># /etc/headscale/config.yaml
server_url: https://headscale.yourdomain.com
listen_addr: 127.0.0.1:8080
metrics_listen_addr: 127.0.0.1:9090

private_key_path: /var/lib/headscale/private.key
noise:
  private_key_path: /var/lib/headscale/noise_private.key

ip_prefixes:
  - 100.64.0.0/10   # Standard Tailscale IP range

db_type: sqlite3
db_path: /var/lib/headscale/db.sqlite

# DERP relay servers (for NAT traversal fallback)
derp:
  server:
    enabled: true
    region_id: 999
    region_code: "hk"
    region_name: "Hong Kong"
    stun_listen_addr: "0.0.0.0:3478"
  urls:
    - https://controlplane.tailscale.com/derpmap/default   # Fallback to Tailscale DERPs

# Epoch/expiry
ephemeral_node_inactivity_timeout: 30m

# ACL (access control)
acl_policy_path: /etc/headscale/acl.hujson

# DNS configuration for magic DNS
dns_config:
  nameservers:
    - 1.1.1.1
    - 8.8.8.8
  domains:
    - yourdomain.internal
  magic_dns: true
  base_domain: yourdomain.internal

Step 3: Nginx and TLS

<code">cat > /etc/nginx/sites-available/headscale << 'EOF'
server {
    listen 443 ssl http2;
    server_name headscale.yourdomain.com;
    ssl_certificate /etc/letsencrypt/live/headscale.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/headscale.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 300;  # Long-lived WebSocket connections
    }
}
EOF

# STUN/DERP port for relay (open in firewall)
ufw allow 3478/udp  # STUN
ufw allow 41641/udp # WireGuard

ln -s /etc/nginx/sites-available/headscale /etc/nginx/sites-enabled/
certbot --nginx -d headscale.yourdomain.com
systemctl enable --now headscale

Step 4: Create Users and Devices

<code"># Create a user (namespace in Headscale)
headscale users create engineering
headscale users create devops

# Generate pre-auth key for device registration
headscale preauthkeys create --user engineering --expiration 24h --reusable
# Output: mkey:abcdef1234567890...

# On each device — connect using Tailscale client with your Headscale server
# macOS/Linux/Windows: install Tailscale, then:
sudo tailscale up \
  --login-server https://headscale.yourdomain.com \
  --authkey mkey:abcdef1234567890...

# List registered devices
headscale nodes list

# ID | Hostname    | Name    | User        | IP           | Online
# 1  | MacBook-Pro | macbook | engineering | 100.64.0.1   | yes
# 2  | sg-prod-vps | sg-prod | devops      | 100.64.0.2   | yes
# 3  | hk-db-01    | hk-db   | devops      | 100.64.0.3   | yes

Step 5: Access Control Policies

<code"># /etc/headscale/acl.hujson — define who can access what
{
  "groups": {
    "group:engineering": ["engineering"],
    "group:devops": ["devops"]
  },
  "hosts": {
    "hk-db": "100.64.0.3",
    "sg-prod": "100.64.0.2"
  },
  "acls": [
    // DevOps can SSH to all servers
    {
      "action": "accept",
      "src": ["group:devops"],
      "dst": ["*:22"]
    },
    // Engineers can access staging but not production DB
    {
      "action": "accept",
      "src": ["group:engineering"],
      "dst": ["sg-prod:443", "sg-prod:80"]
    },
    // Block direct DB access from engineering
    {
      "action": "deny",
      "src": ["group:engineering"],
      "dst": ["hk-db:5432"]
    }
  ]
}

Step 6: Connect Servers without Public Exposure

<code"># Your database server joins the Headscale network
# No public port needed — access only via WireGuard mesh

# On production VPS (install Tailscale, auth to your Headscale):
sudo tailscale up \
  --login-server https://headscale.yourdomain.com \
  --authkey mkey:PREAUTH_KEY \
  --advertise-tags=tag:production

# Now from dev laptop: access PostgreSQL over mesh VPN
psql postgresql://db_user:pass@100.64.0.3:5432/mydb
# Port 5432 never exposed publicly — only accessible via WireGuard tunnel

# SSH to any server by mesh hostname (magic DNS)
ssh admin@hk-db.yourdomain.internal

Headscale vs Tailscale Cloud Pricing

Factor Headscale (HK VPS) Tailscale Cloud
Cost (10 users) ~$20–40/month (VPS) $60/month ($6/user)
Cost (50 users) ~$20–40/month (same VPS) $300/month
Device limit Unlimited 3 per user (free) / unlimited (paid)
Data on your servers Yes No (Tailscale cloud)
Coordination latency (from Asia) Low (HK VPS) Higher (US servers)
Feature parity ~90% (no taildrop, some enterprise features) 100%

Conclusion

Headscale on a Hong Kong VPS gives Asia-Pacific engineering teams a self-hosted Tailscale mesh VPN — every device and server gets a WireGuard-encrypted tunnel, coordination happens at HK CN2 GIA latency rather than from a US cloud, and device metadata stays on your own infrastructure. For teams of 10+ connecting developers across Hong Kong, Singapore, and mainland China to shared infrastructure, Headscale saves $60–300/month over Tailscale Teams pricing while adding coordination server proximity for better NAT traversal in the Asia-Pacific region.

Secure your team network: Browse Server.HK Hong Kong VPS plans — a 1–2 GB plan is sufficient for Headscale serving up to 100 devices; it’s a lightweight coordination service, not a traffic relay.

Related articles

More in VPS & ServersServer setup guides