Install CapRover With No Public Ports: A Tailnet-Only Self-Hosting Server

Share

Install CapRover With No Public Ports: A Tailnet-Only Self-Hosting Server

The usual CapRover guide opens four ports because the platform is built for the public internet. If you do not want the internet at all, the four-port path is wrong for you from its first line. This installs the same platform on a server that answers nothing from outside, then talks to it from a Tailscale private network only.

What you will build

A VPS with ufw default deny incoming, no port 80, 443 or 3000 rule on the public interface, and CapRover running behind a chain that drops new inbound connections before Docker ever sees them. The dashboard, the app domains and certificate issuance all travel over a Tailscale overlay network. Nothing on the box has a public listener.

The result is a self-hosting host that a scanner cannot find because there is no open port to find, and which stays reachable to you from any device on your tailnet — phone, laptop, another server.

Tailscale is a mesh VPN: it assigns every device a private 100.x.y.z address and lets them talk to each other as if on one local network, without a port open on the public interface. Calling it "a VPN" undersells what it does here; the useful property is that it gives you a private network on top of a public one, and you close the public one.

Before you start

  • A VPS where you have root. This guide was worked through on Ubuntu 26.04.1 LTS, kernel 7.0.0-44-generic, with Tailscale 1.104.7 and the caprover/caprover:1.16.1 image. The Tailscale part is distro-agnostic; the CapRover image targets AMD64 and ARM64.
  • A domain whose DNS you control. caprover.com is CapRover's own docs and tutorial domain; this guide uses a fictional captain.example.com everywhere you'd substitute your own.
  • A Cloudflare account for that domain, because certificates here are issued with the DNS-01 challenge through Cloudflare's API. You need a zone-scoped API token, not the global key. This is the standard CapRover doctored setup combined with your own Tailscale.
  • Tailscale installed on the server and at least one client device, both logged into the same tailnet. The first 24 hours on a new VPS covers the SSH and UFW groundwork this guide assumes.

Two prerequisites deserve emphasis before the commands, because neither is optional and both are easy to get wrong.

The tailnet comes first. CapRover provisioned on a host it cannot reach is CapRover you cannot administer. Install Tailscale, bring the box onto your tailnet, and confirm tailscale ip -4 returns a 100.x address before you touch anything else.

DNS-01, not HTTP-01. A host with no public port 80 cannot complete Let's Encrypt's HTTP-01 challenge, where the CA connects to you. DNS-01 flips it: you create a TXT record in DNS, the CA queries DNS, no inbound connection involved. That is the only challenge that works here, and it also enables wildcards. Let's Encrypt explains both challenge types plainly.

1. Close the server to the internet

Your UFW posture is the whole point of this guide, so set it before CapRover exists.

apt update && apt install -y ufw
ufw default deny incoming
ufw default allow outgoing
ufw allow from 10.0.0.1 to any port 22 proto tcp   # your tailnet or home SSH source
ufw enable
ufw status verbose

That last rule is the only deliberate opening, and it is SSH restricted to your source. There is no ufw allow 80, no ufw allow 443, no ufw allow 3000 — the three ports the public guide insists on.

The gap this leaves is the one most guides never mention. UFW deny incoming does not stop Docker. Docker publishes a container's port with a DNAT rule in PREROUTING, which the INPUT chain where UFW lives never sees. CapRover publishes 80, 443 and 3000, so with UFW alone those containers are reachable from the public interface while ufw status reports you closed everything. A firewall that tells you everything is closed while the published ports still answer — what exactly did it close? The fix is a guard that drops new inbound on the public interface before Docker's NAT rules run:

iptables -t mangle -N CAP-VPN-ONLY
iptables -t mangle -A PREROUTING -i eth0 -j CAP-VPN-ONLY
iptables -t mangle -A CAP-VPN-ONLY -m conntrack --ctstate ESTABLISHED,RELATED -j RETURN
iptables -t mangle -A CAP-VPN-ONLY -m conntrack --ctstate NEW -j DROP

Verified against the live box:

$ sudo iptables -t mangle -L CAP-VPN-ONLY -n --line-numbers
Chain CAP-VPN-ONLY (1 references)
num  target     prot opt source               destination
1    RETURN     all  --  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
2    DROP       all  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW

The provider's external firewall panel is secondary here: the host guard above is what actually controls what a scanner reaches on 41641 and every other port, and it only filters inbound traffic, so the WireGuard tunnel and any outbound traffic are unaffected regardless of what a provider's "security panel" says it blocks.

Because Docker rewrites routes on restart, this chain must survive a docker.service reload or your guard silently vanishes. Point Docker at it with a systemd drop-in and re-run the guard on every start — the pattern that worked here is a fail-closed unit that requires the guard service before Docker runs, plus a short timer that re-verifies it every few minutes and repairs if a flush wiped it. The detail that matters: Requires= (so a failed guard stops Docker) rather than just After= (which only orders it), because the whole point is that a box with no guard does not expose itself. This is the same principle as the first-24-hours guide's insistence on a default-deny posture, taken one layer closer to the containers.

2. Put the server on your tailnet

Install Tailscale with its one-liner, which sets up the official repo:

curl -fsSL https://tailscale.com/install.sh | sh
tailscale up
tailscale ip -4

tailscale up prints a login URL the first time; authenticate with the account that owns the tailnet. Confirm tailscale ip -4 returns 100.x.y.z:

$ tailscale ip -4
100.64.0.7

That 100.x address is now the only route into the box's management plane. From here on, the dashboard and the apps are reached at 100.x addresses or at DNS names that resolve through Tailscale's own resolver — never through a public IP.

If your tailnet runs a custom DNS (NextDNS and similar are common here), 100.x.ts.net hostnames do not resolve, because Tailscale's MagicDNS is not what you configured. That is fine and expected; you use literal 100.x addresses for the GUI instead, exactly as this guide does.

3. Install CapRover the private way

CapRover's own install command publishes the three ports and, by default, sits in a mode that aborts if port 80 is not reachable for its compatibility check. On a locked box that check finds port 80 closed and stops. Set the main node IP to loopback so the check has nothing to reach and the container proceeds:

docker run -d --name caprover-bootstrap \
  -e MAIN_NODE_IP_ADDRESS='127.0.0.1' \
  -e ACCEPTED_TERMS='true' \
  -p 80:80 -p 443:443 -p 3000:3000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /captain:/captain \
  caprover/caprover:latest

Two notes on that command. The -e ACCEPTED_TERMS=true flag is mandatory — without it the container exits immediately. And the three -p flags are still required even though we are about to close those ports at the firewall, because the platform binds them internally; the mangle guard is what keeps them unreachable from outside.

Do not pre-initialise Docker Swarm first. If the node is already part of a swarm, bootstrap fails with "node is already part of a swarm". Let the bootstrap initialise it. If you already ran docker swarm init, undo it with docker swarm leave --force before starting.

4. Point a wildcard at the tailnet address

CapRover needs a root domain so every app it creates gets a subdomain. Point a wildcard record at the server's tailnet address — grey-cloud, never proxied through Cloudflare's orange cloud, because the edge cannot reach a 100.x origin:

*.apps.example.com   A   100.64.0.7
apps.example.com     A   100.64.0.7

The grey-cloud requirement matters. CapRover terminates TLS itself with certificates it issues, and a proxied record inserts Cloudflare's edge between the browser and a 100.x origin Cloudflare cannot route to. The installing-caprover guide has shown the grey-cloud record for a public IP; the only difference here is that the value is a 100.x address.

5. Set the CapRover root domain

CapRover has a CLI for this, and it is the reliable path because the dashboard leaves server setup to it.

npm install -g caprover
caprover serversetup

Answer the prompts: the server IP is your tailnet 100.x address, the root domain is apps.example.com, and you set an email for certificate renewal. The web root (for DNS-01, the plaque part) is covered in the dedicated DNS-01 guide. On this host the server setup ran through the captain API rather than the interactive CLI, which sidesteps the server-IP prompt entirely: authenticate to https://captain.<root-domain>/api/v2 and drive the setup over HTTP, so there is no prompt asking for an address. If you take the CLI route instead, it asks for a server address — on a tailnet-only box that is your 100.x address, not a public one.

6. Issue certificates with DNS-01

This is where a tailnet-only host parts ways with the public-port guide decisively, and it deserves its own piece rather than half a section here. The short version: build a certbot image that carries the Cloudflare plugin, put a zone-scoped token in an INI file, override CapRover's certbot command to prefer DNS-01, and force a re-issue so each renewal config flips from webroot to dns-cloudflare.

Everything about that — the image tag matching the platform's certbot version, the sleeping-container entrypoint, the skipVerifyingDomains flag, and deliberately why the forced re-issue is necessary — is worked through end-to-end in the companion DNS-01 post. Use that as the reference for this step; the certificate path is identical because a tailnet-only host requires DNS-01 by definition.

7. Enable HTTPS on the root domain

Once the DNS-01 certificate exists for the wildcard, switch the dashboard onto HTTPS. On CapRover this is the /enablessl/ operation on the root domain. After it runs, the API base flips from http://<ip>:3000 to https://captain.apps.example.com/api/v2/*, and HTTP calls start returning 302 redirects to :443. If you script anything against the API, that is the change to watch for — it is easy to mistake a 302 for something broken when it is actually the platform behaving correctly.

Verify the served certificate matches the one on disk:

$ echo | openssl s_client -connect 100.64.0.7:443 -servername captain.apps.example.com 2>/dev/null \
    | openssl x509 -noout -subject -issuer -dates
subject=CN=captain.apps.example.com
issuer=C=US, O=Let's Encrypt, CN=YE2
notBefore=Nov 20 14:14:14 2026 GMT
notAfter=Feb 18 14:14:13 2027 GMT

A Let's Encrypt issuer and a ~90-day expiry mean the DNS-01 setup owns the certificate. The public guide's dashboards reachable at :3000 case cannot happen here because :3000 has no public listener to begin with.

8. Deploy an app and test the path

Deploy a test app through the dashboard — say, an nginx hello — and confirm the loop end to end:

# from a device on the tailnet
curl -s -o /dev/null -w '%{http_code}\n' https://hello.apps.example.com
# from the public internet — must fail
curl -s --max-time 5 http://<PUBLIC_IP>:80 -o /dev/null -w '%{http_code}\n'

The first returns 200; the second times out. That pair is the whole point: the app works for you and is absent to everyone else.

Traps that cost real time

docker ps filters match more than one container. docker ps -qf name=captain returns captain-certbot too, because a filter is a substring match. Commands meant for the platform container ran against the certbot container and failed oddly. Target the exact service (or read certificates from the host path, not a container).

UFW "active" does not mean Docker is closed. The published-port gap in section 1 files under "the firewall looked fine and it wasn't." Re-verify after every docker.service restart, because restart rewrites routes and can drop your guard chain. This is why the systemd Requires= + timer exists, not as ceremony.

A .ts.net name failing to resolve under a custom DNS is expected. Tailscale's MagicDNS is off when you run NextDNS or similar as the tailnet DNS. Reach the GUI by 100.x address, not hostname, and move on.

Certificate verification after a docker service update needs the service to converge first. Checks run during the regeneration window return connection errors that look identical to misconfiguration. Wait for docker service ls to report your services 1/1 and re-run.

Why not just keep the dashboard on port 3000

The public guide notes you can restrict :3000 after setup and calls it "not ideal." On a tailnet-only host, "restrict" is not a compromise you make after the fact — it is the design. Zero public listeners means there is no port to forget to close, and no per-app decision about what the world can reach. The cost is real and worth stating: you lose the ability to fling a shareable URL at someone outside the network, and outbound-only hosts cannot be used as public web servers. If you want anything public-facing, you run a separate public box — which is a different threat model and a separate server. For a private personal stack, the trade is clearly on the side of closing the ports.

What you end up with

A CapRover host on the tailnet only: no public port 80, 443 or 3000, a mangle guard that drops new inbound before Docker sees it, valid Let's Encrypt certificates issued and renewed over DNS-01 with no inbound dependency, and a dashboard addressed at a 100.x address from your devices. The public guide's how-to-self-host-searxng then applies verbatim on top of this host, with the sole difference that its apps are addressed over the tailnet rather than over public DNS.

The piece of this setup that recurs is the mental flip: a well-guarded server is not one with a good firewall and a handful of open ports; it is one with no reason to open them. CapRover on a closed box still deploys apps, still issues certificates, and still gives you a dashboard — it just gives it to you, not to the internet.

For reference: CapRover's self-hosting docs, Tailscale's install documentation, and Let's Encrypt's challenge types.

## Convertkit Newsletter