# Keep self-hosted apps private with Tailscale

> Put n8n, Vaultwarden, Home Assistant or any app you self-host on your tailnet instead of the public internet, at an HTTPS address only your own devices can open. On an EnvHaven workspace, the coding agent does the setup from one request.

_Updated November 23, 2026_

Most apps people self-host have one user, or one household: a password manager, a photo library, documents, home automation, a workflow tool. On a public address such an app is one login screen away from anyone who finds it, and many make the first visitor their administrator until setup is done. Some docs advise against public exposure outright; Home Assistant's security page is one ([Home Assistant](https://www.home-assistant.io/docs/configuration/securing/)). A tailnet is the quieter home. Tailscale joins your devices into a private network over encrypted WireGuard connections that work across firewalls without opening ports ([Tailscale](https://tailscale.com/docs/concepts/what-is-tailscale)), and an app on it answers only to those devices.

## Just ask your agent

On an EnvHaven workspace the setup is one request to the coding agent. First, three things in Tailscale:

1. **An auth key.** On the admin console's Keys page, select **Generate auth key** ([Tailscale](https://tailscale.com/docs/features/access-control/auth-keys)), and save the key in the workspace's **Vars** pane as `TS_AUTHKEY`. The pane keeps it write-only, and the agent reads it from the environment without printing it.
2. **HTTPS certificates.** On the admin console's DNS page, under **HTTPS Certificates**, select **Enable HTTPS** ([Tailscale](https://tailscale.com/docs/how-to/set-up-https-certificates)). Tailscale Serve, which puts the app on your tailnet, needs it. Turning it on publishes your machine names and your tailnet's name in public certificate transparency logs.
3. **Tailscale on your devices**, such as your phone and your laptop, signed in to the same account ([iPhone and iPad](https://tailscale.com/docs/install/ios), [Android](https://tailscale.com/docs/install/android)).

Then open the workspace, tap **Launch** to start any coding agent, and ask for the app by its EnvHaven page:

```text
Set up Vaultwarden on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/vaultwarden.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

The agent installs the app the way its page describes, puts it on your tailnet, and sends you its address, which looks like `https://vaultwarden.tail1234.ts.net`. Every app on [the self-hosting pages](https://envhaven.com/self-host) has this request ready to copy.

## What you get

- **An address only your devices can open.** Nothing about the app listens on the public internet, so its first-run screen is never exposed while you finish setting it up.
- **Several apps at once.** A workspace has one public preview URL, but every Docker app you put on your tailnet gets a name of its own.
- **HTTPS with a real certificate** for that name. The first request is slow while the certificate is issued ([Tailscale](https://tailscale.com/docs/solutions/host-private-server-docker)).
- **No bill for personal use.** Tailscale's Personal plan is free, for up to 6 users with unlimited devices of theirs ([pricing](https://tailscale.com/pricing)).

## How the agent does it

### Docker apps, on Plus and Pro

A small Tailscale container runs beside the app, from Tailscale's official image, and the app shares its network ([Tailscale](https://tailscale.com/blog/docker-tailscale-guide)). The Tailscale container joins your tailnet under the app's name and passes HTTPS requests to the app. It uses userspace networking, the image's default, which needs neither extra privileges nor a network device ([Tailscale](https://tailscale.com/docs/features/containers/docker/docker-params)). Both containers restart on their own, so the app keeps its address through workspace restarts and updates, and nothing is published on the server's public address.

### Apps without Docker, on any plan

Tailscale runs in the workspace itself, as the workspace user, in userspace networking mode, which exists for systems without the network device a VPN normally needs ([Tailscale](https://tailscale.com/docs/concepts/userspace-networking)). We checked that it starts this way in EnvHaven's current image. Its program and its state live in your home folder, so they survive workspace updates, and the address it serves comes back whenever it starts ([Tailscale](https://tailscale.com/docs/reference/tailscale-cli/serve)). The process itself stops with a restart or an update, so ask the agent to start Tailscale again afterwards.

## Your dev servers on your tailnet

With Tailscale running in the workspace, the workspace is a machine on your tailnet too, and a connection to it reaches the same port on the workspace ([Tailscale](https://hub.docker.com/r/tailscale/tailscale)). Your phone and laptop can open any dev server there by name, such as `http://my-workspace:5173`, privately and several at once, even one that listens only on localhost. The public preview URL keeps working beside it. Ask the agent: "Put this workspace on my tailnet as my-workspace."

## Instructions for the agent

The agent reads these from this page's Markdown copy. They also work pasted on their own.

```text
Put the app on my tailnet instead of the preview URL. The auth key is in $TS_AUTHKEY; never print it.
- Set the app up as its EnvHaven page describes, but publish no port, add no relay to the preview URL, and leave the preview URL alone.

With Docker (Plus and Pro):
- Add a Tailscale service to the app's compose file: image tailscale/tailscale:stable; environment TS_AUTHKEY=${TS_AUTHKEY}, TS_HOSTNAME=<app name>, TS_STATE_DIR=/var/lib/tailscale and TS_SERVE_CONFIG=/config/serve.json; volumes ./tailscale/state:/var/lib/tailscale and ./tailscale/config:/config; restart: unless-stopped. Leave TS_USERSPACE at its default, with no /dev/net/tun and no NET_ADMIN.
- Give the app's web service network_mode: service:<the Tailscale service>, and remove its ports.
- Write ./tailscale/config/serve.json as {"TCP":{"443":{"HTTPS":true}},"Web":{"${TS_CERT_DOMAIN}:443":{"Handlers":{"/":{"Proxy":"http://127.0.0.1:<app port>"}}}},"AllowFunnel":{"${TS_CERT_DOMAIN}:443":false}}
- Check it with docker exec <Tailscale container> tailscale --socket=/tmp/tailscaled.sock serve status.

Without Docker:
- Download the static build for linux amd64 from https://pkgs.tailscale.com/stable/ (the ?mode=json listing names the current tarball), check it against the .sha256 file beside it, and unpack tailscale and tailscaled into ~/.local/share/tailscale/bin.
- Make ~/.local/bin/tailscale a wrapper that runs ~/.local/share/tailscale/bin/tailscale --socket=$HOME/.local/share/tailscale/tailscaled.sock "$@", so the plain tailscale command reaches this daemon.
- In a tmux window named tailscale, run ~/.local/share/tailscale/bin/tailscaled --tun=userspace-networking --statedir=$HOME/.local/share/tailscale/state --socket=$HOME/.local/share/tailscale/tailscaled.sock
- Run tailscale up --auth-key="$TS_AUTHKEY" --hostname=<name>, then tailscale serve --bg <app port>.
- After a workspace restart or update, start tailscaled again in its tmux window; the sign-in and the serve settings come back with it.

Either way:
- Set the app's public-address settings to https://<name>.<tailnet>.ts.net; tailscale status shows the tailnet's name.
- If Tailscale says HTTPS is not enabled, ask me to turn on HTTPS certificates on the DNS page of the admin console.
- Test the address from another device on the tailnet: in userspace mode the workspace may not reach its own served address.
- Send me the address, suggest I turn off key expiry for the new machine in the admin console so it stays connected, and tell me what to back up, the Tailscale state folder included.
```

Turning off key expiry is how Tailscale's docs suggest keeping always-on machines connected ([Tailscale](https://tailscale.com/docs/install/linux)); without it, a machine signs out when its key expires, 180 days by default ([Tailscale](https://tailscale.com/docs/features/access-control/auth-keys)).

## When something has to be public

Webhooks from outside services, a site other people visit, a booking link you hand out: these need a public address, so keep those apps on the workspace's preview URL. Tailscale's own answer is Funnel, in beta, which opens a served address to the internet on port 443, 8443 or 10000 and needs a setting in your tailnet's policy that its CLI walks you through ([Tailscale](https://tailscale.com/docs/features/tailscale-funnel)).

## Similar tools

- **Headscale** is an open-source, self-hosted control server for Tailscale clients ([Headscale](https://headscale.net/stable/)). It runs on a server reachable from the internet, and your devices keep using Tailscale's apps, pointed at it.
- **NetBird** is an open-source network of the same kind, with a userspace mode that needs no network device ([NetBird](https://docs.netbird.io/client/environment-variables)).
- **ZeroTier** connects devices as if they shared a local network; inside a container its standard client needs a TUN device and extra privileges ([ZeroTier](https://docs.zerotier.com/docker/)), which a workspace does not give.
- **WireGuard** is the VPN protocol under Tailscale's connections ([WireGuard](https://www.wireguard.com/)); its userspace build still creates a TUN device ([WireGuard](https://www.wireguard.com/xplatform/)).

## Without a workspace

On a home server or a VPS of your own, install Tailscale from its packages ([Tailscale](https://tailscale.com/docs/install/linux)) and use the same two patterns: a Tailscale container beside each Docker app, or `tailscale serve --bg` on the machine for everything else ([Tailscale](https://tailscale.com/docs/solutions/host-private-server-docker)).

## Keep reading

- [Self-host apps with your agent](https://envhaven.com/self-host)
- [Claude Code over Tailscale](https://envhaven.com/guides/claude-code-over-tailscale)
- [Mesh VPN](https://envhaven.com/glossary/mesh-vpn)
- [Tailscale Funnel alternatives](https://envhaven.com/alternatives/tailscale-funnel)

Source: https://envhaven.com/guides/self-host-privately-with-tailscale
