← All notes

Networking

Publishing services with zero open ports

· 5 min read

Today my router still forwards one port: 443, to the reverse proxy. It works, but it's a door, and every scanner on the internet knocks on it. This note is the plan for closing it while still reaching everything from anywhere.

The shape of it

The idea is to turn the connection around. Instead of the internet connecting in to my house, a small daemon at home connects out to Cloudflare and keeps that connection open. Requests for my domain arrive at Cloudflare, travel down the existing tunnel, and land on the reverse proxy inside the LAN.

  • Cloudflare holds DNS and terminates the public TLS connection.
  • cloudflared runs in a small container and keeps the tunnel up.
  • Nginx Proxy Manager routes each hostname to the right service and handles certificates for internal names.

Setting up the tunnel

Create a tunnel in the Cloudflare Zero Trust dashboard, copy its token, and run the connector somewhere that's always on:

docker run -d --name cloudflared --restart unless-stopped \
  cloudflare/cloudflared:latest tunnel --no-autoupdate run \
  --token <your-tunnel-token>

Then add a public hostname for each service, pointing at its address on the LAN. Cloudflare creates the DNS record for you.

Watch out: if the service behind the tunnel cares about the client's IP (Home Assistant does), tell it to trust the proxy. Otherwise every request looks like it came from the tunnel and logins get blocked.

Then close the doors

Once each service answers through the tunnel, delete the port forwards one at a time and check it still works from a phone on mobile data. When the list is empty, run an outside port scan against your home IP to be sure nothing answers.

Things to get right

  • Put anything admin-only (Proxmox, the NAS) behind a Cloudflare Access policy, or keep it off the tunnel entirely and use a VPN.
  • Run two connectors on different hosts. If one goes down for an update, the other keeps the tunnel up.
  • Write the hostname list down. Six months later you'll want to know why test2 exists.