How I Configured My Mac Mini to Be My Main Server

By Esteban Trillo19 min readupdated HomelabmacOSCloudflareSecurity

No public ingress. One outbound tunnel. FileVault off.
No public ingress. One outbound tunnel. FileVault off.

A Mac mini sitting on a shelf is a perfectly good server. It is quiet, it sips power, and it already runs Docker. The part I did not want was the part every home-server tutorial starts with: log into your router, find the port forwarding page, and point :443 at your machine.

So I built it without that page. No forwarded ports, nothing on the Mac listening for the public internet, and yet the app is still on a real domain at app.devtrillo.com and I can still administer the machine from a coffee shop.

Why I care about the front door

An exposed service used to be a slow problem. Someone had to find your IP, notice the version banner, go read about that version, and then write something that actually worked against it. That took a person with time and interest, and there were not many of those pointed at a hobby box in someone’s living room. That chain is now much cheaper. A model can read a banner, tell you what software it probably is, and produce a plausible first attempt in about a minute. I do not think that makes attacks magic, but it does remove the boring parts, and for a machine like mine the boring parts were most of the protection.

I do not need to argue about AI to justify this setup, though. The internet is already scanned continuously, all of it, on a schedule, and that is not a theory you have to take on faith. You can search the results yourself: Shodan1 and Censys2 index reachable services and let you look up your own address. Open a port and you are in a public index within a day or two, sitting next to every other host running the same software you are.

So I stopped thinking about who might knock and started thinking about the sockets instead. Every service listening on a public address is something I have to keep patched, keep configured correctly, and keep thinking about at eleven at night when a CVE lands. I decided there would be zero of them.

The source, and what I changed

The architecture here comes from a video about running this pattern on a VPS.3 The idea is the same: a private path for administration, a tunnel for the public app, and nothing accepting inbound connections. What I did was move it onto a Mac mini at home, which turned out not to be a small edit. macOS is not Linux, Docker Desktop is not a daemon that starts at boot, and a home router is a different network shape than a cloud provider’s. Those three differences are what most of this post is about.

The experience described here is mine, not the video creator’s. Where I have not verified something yet, I say so rather than borrowing someone else’s confidence for it.

What I am starting with

  • A Mac mini running macOS Tahoe 26.4
  • A normal home router doing NAT. No port forwarding rules.
  • The built-in macOS firewall on.
  • Docker Compose. No Kubernetes, no Coolify, no Dokploy.
  • An app that is already containerized. Mine is a SvelteKit app that listens on port 3000 in its container.
  • A domain on Cloudflare, serving the app at app.devtrillo.com.

I am assuming your app already builds and runs in a container, because packaging a SvelteKit app is a different post. What matters here is the shape: there are two halves to this setup, administration and the app itself. Administration is private, the app is public, and the two never share a path into the machine.

Mac mini behind a Cloudflare TunnelA visitor resolves app.devtrillo.com on Cloudflare DNS and reaches Cloudflare's edge. At home, a router doing NAT forwards no ports, so internet scanners like Shodan and Censys get no inbound connection. Inside the Mac mini, Docker Compose runs cloudflared next to the app on port 3000. cloudflared dials out to the edge on port 7844 over QUIC, and the edge sends requests back down that tunnel to the app. Admin happens from a laptop on the tailnet, over SSH on port 22 through Tailscale. The macOS firewall is defense in depth.InternetvisitorbrowserscannersShodan, CensysCloudflareDNSapp.devtrillo.comedgetunnel routeHomerouterNAT, no forwardsMac minimacOS firewallTailscaleDocker Composecloudflaredapp:3000Tailnetlaptopadminhttpsoutbound :7844 QUICvia tunnelSSH :22 over Tailscaleno inbound

Private side: admin over Tailscale

I want a shell on this machine from anywhere without a public SSH port, and Tailscale is how I get it. It gives every one of my devices a private address in the 100.64.0.0/10 range that only my own devices can reach, and SSH then runs over that address instead of over anything the wider internet can see.

Install Tailscale

Tailscale ships three macOS builds. The docs recommend the standalone variant from their package server over the Mac App Store one.5 I used the standalone build, because it can install a CLI shim at /usr/local/bin/tailscale, which the App Store build cannot.6

With the App Store build you would call the binary inside the app bundle instead:

Terminal window
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"

Once it is signed in, find the Mac’s Tailscale address:

Terminal window
tailscale ip -4
# 100.x.y.z
tailscale status

Turn on Remote Login

This is macOS’s own SSH server, and Apple calls it Remote Login. Go to Apple menu → System Settings → General → Sharing, scroll down to Remote Login, and turn it on. Click the info button next to it to get at the options, because two of them matter.

Set Allow access for to “Only these users” and add just your own account, since the default is every user on the machine. Then leave Allow full disk access for remote users off. Apple’s own wording is that it gives remote users full access to the disk, and I do not need anything like that for a shell.

There is a CLI equivalent, sudo systemsetup -setremotelogin on,7 but it comes with a catch: since Catalina, the process running systemsetup needs Full Disk Access before that flag works, so you would have to grant it to your Terminal first.8 I used the System Settings pane and skipped the whole detour.

Restrict port 22 in Tailscale

Turning on Remote Login opens port 22 to everything that can reach the Mac, and right now that means my LAN plus my whole tailnet. The LAN half I am fine with. The tailnet half I can narrow, using Tailscale’s policy file, which now prefers grants over the older acls block. ACLs will keep working indefinitely, but they get no new features, so new configuration should use grants.10

Here is the shape of it. This is a placeholder policy, not a tested one. Replace the login and confirm it against your own tailnet before you rely on it for anything.

{
"tagOwners": {
"tag:admin": ["<YOUR_TAILSCALE_LOGIN>"]
},
"grants": [
{
"src": ["<YOUR_TAILSCALE_LOGIN>"],
"dst": ["tag:admin"],
"ip": ["tcp:22"]
}
]
}

Then tag the Mac as tag:admin in the admin console.

Screen Sharing stays on the LAN

I keep Screen Sharing on for the times I need the actual desktop rather than a shell. It lives in System Settings → General → Sharing → Screen Sharing, and again I set Allow access for to only my account.11

I want to be precise about what “LAN only” means here, though, because macOS does not have a switch for it. Screen Sharing listens on TCP and UDP 5900,12 and there is no Apple-documented way to bind it to a single network or restrict it by source address. What keeps it local is the network around it rather than anything on the Mac: the router forwards no ports, so nothing outside the house can reach 5900, and my Tailscale policy grants only tcp:22, so nothing in the tailnet can reach it either. That is a real restriction and I trust it. It just lives in the router and the tailnet instead of in macOS, which is worth knowing if you ever change either one.

The firewall, and what it actually does

Turn on the macOS firewall in System Settings → Network → Firewall,13 then set your expectations correctly, because I had this part wrong at first. Apple’s documentation is blunt about what it is: the application firewall in macOS controls access by app, not by port.12 That means it cannot express “allow port 22 from 100.64.0.0/10 and my LAN, deny everything else,” because it is not that kind of tool. Apple also notes that turning on a sharing service opens a port for that service, and that some signed and system processes get through without ever appearing in the app list.13

I could write pf rules and get real per-port filtering, and I chose not to. Hand-written packet filter rules on a machine I only administer remotely are an excellent way to lock myself out of it, and the router is already dropping unsolicited inbound traffic. So the macOS firewall here is defense in depth rather than the thing the design rests on.

deep diveWhat about IPv6? NAT does not cover it.

NAT is the reason your LAN is not directly reachable over IPv4: there is simply no route in without a forwarding rule. That argument does not carry over to IPv6 at all. With IPv6 your Mac can hold a globally routable address with no address translation standing in the way, so whether it is reachable comes down to your router’s firewall rather than to NAT.

Which means this has to be checked rather than assumed. Find the global address first:

Terminal window
ifconfig en0 inet6

Look for a 2000::/3 address that is not marked temporary or link-local. Then, from a network that is not yours, try to reach it. I have not run this test yet. Until I do, I am not claiming my IPv6 ingress is closed, and neither should you.

Public side: the app through a Cloudflare Tunnel

Now the other half, which has to satisfy two things at once: the app needs to be on the internet, and nothing on the Mac is going to accept an inbound connection. A Cloudflare Tunnel resolves that by inverting the direction of travel. A small process called cloudflared runs next to my app and dials out to Cloudflare, and it keeps that connection open. Requests to app.devtrillo.com land on Cloudflare’s edge, and Cloudflare hands them back down the connection my machine already opened.

Every port involved is therefore outbound. cloudflared needs port 7844 out, UDP for QUIC with TCP as the HTTP/2 fallback, and Cloudflare’s own firewall guidance for it is to block all ingress and allow only egress.14

Create the tunnel in the dashboard

I used a dashboard-managed tunnel, which means the routing configuration lives in Cloudflare rather than in a config file on my Mac. In the Cloudflare dashboard, go to Networking → Tunnels and create one.15 If you are following along from an older guide, note that this page moved: it used to sit under Zero Trust → Networks → Tunnels, and most of the tutorials still say so. Copy the token the dashboard gives you when the tunnel is created, and treat it like a password, because it is the entire credential for that tunnel.

Then open the tunnel’s Routes tab, add a route, choose Published application, and fill in three fields:

  • Subdomain: app
  • Domain: devtrillo.com
  • Service URL: http://app:3000

Your domain has to already be on Cloudflare for this part.15 Adding the route creates the CNAME to <UUID>.cfargotunnel.com for you, as long as you are on a full DNS setup. On a partial setup you add that record yourself.16

The Compose file

name: homeserver
services:
app:
build: .
expose:
- "3000"
restart: unless-stopped
tunnel:
image: cloudflare/cloudflared:latest
command: tunnel --no-autoupdate run
environment:
TUNNEL_TOKEN: ${TUNNEL_TOKEN}
depends_on:
- app
restart: unless-stopped

Four things in there are deliberate.

No ports: on either service. This is the whole point of the file. expose declares that the app listens on 3000 inside the Compose network without publishing anything to the host,18 and cloudflared reaches it at app:3000 over that same network, so nothing on the Mac ever binds a socket the rest of the machine or the LAN can hit. If you add ports: - "3000:3000" out of habit, which is easy to do while debugging, you have quietly undone the entire design.

No top-level version:. It is obsolete, Compose only keeps it for backward compatibility, and it will warn you about it.19 Several of Cloudflare’s own examples still carry it, which is how you can tell they have not been touched in a while.

The token goes in as an environment variable rather than on the command line. cloudflared supports TUNNEL_TOKEN as an alternative to the --token flag,20 and I prefer it, because a token sitting in command: shows up in the output of docker ps and docker inspect for anything that can talk to the daemon.

restart: unless-stopped on both services. Docker will restart the container when it fails and again after the daemon itself restarts, but it will leave alone anything I stopped deliberately.21 The --no-autoupdate in the command belongs to the same instinct: it turns off the update check cloudflared otherwise runs every 24 hours,20 and I would rather pull a new image when I decide to than have a connector replace itself underneath a running site.

Keep the token out of git

.env
TUNNEL_TOKEN=<TUNNEL_TOKEN>
.gitignore
.env

Compose picks up .env from the project directory automatically and uses it to interpolate ${TUNNEL_TOKEN} into the Compose file.22 The mechanism is worth understanding because it trips people up: a variable sitting in .env does not reach the container on its own. It only gets there because I wrote TUNNEL_TOKEN: ${TUNNEL_TOKEN} under environment, which reads the interpolated value and passes it in. Drop that line and the container starts with no token at all.

Bring the stack up:

Terminal window
docker compose up -d
docker compose logs -f tunnel

Since version 2026.5.2, cloudflared runs connectivity pre-checks on startup and tells you what failed: DNS resolution, UDP and TCP on 7844, management API reachability.23 You can also run them without starting a tunnel:

Terminal window
docker compose run --rm tunnel tunnel diag

The reboot problem, and the tradeoff I took

This is the part of running a server on macOS that has no clean answer, and I want to walk through why rather than just hand you the setting.

Docker Desktop on macOS is a user application, not a system daemon. There is a setting for starting it automatically, Settings → General → “Start Docker Desktop when you sign in to your computer”, and it is off by default, so turn it on.24 But read the wording, because it is doing real work: when you sign in. Docker Desktop does not start at boot. It starts when a user session exists, and its socket even lives at a per-user path. So after a power cut the Mac boots to a login window and sits there, and my app stays down until a human walks over and types a password. For a machine whose entire job is to be reachable, that is a failure.

The fix is automatic login, under System Settings → Users & Groups → “Automatically log in as”.25 And that requires FileVault to be off, because Apple disables automatic login whenever FileVault is on.26 You turn it off in System Settings → Privacy & Security → FileVault → Turn Off.27 Before you do, read the next box properly.

There is one nuance worth knowing before you commit to any of this. On macOS Tahoe 26, Apple added the ability to unlock FileVault over SSH after a restart, provided Remote Login is enabled and a network connection is available.28 That is genuinely useful and it is also not a complete solution to my problem: it gets the disk unlocked and the machine booted, but it does not create the logged-in user session that Docker Desktop needs before it will start. Whether you can get the whole stack back that way, with FileVault left on and the unlock done remotely, is the experiment I most want to run. I have not run it. If it works it is strictly better than turning encryption off, and I would take it over what I describe above.

One last thing on encryption, because it gets misread often. Apple silicon and T2 Macs still encrypt the disk at the hardware level even with FileVault off.27 That is not equivalent protection. It happens without your password, which means it does not stop anyone who can boot the machine.

Verification checklist

A setup is not done because the site loaded once. These are the checks that actually prove the claims I made above, and the ones I have not run yet are marked as such, because a checklist you have only half-completed is worse than no checklist at all.

Router

  • Open the router admin page and confirm the port forwarding table is empty. Also check for UPnP, which can add rules without you.
  • From a network that is not yours, confirm nothing answers on your public IPv4. Not yet run.
  • Get the Mac’s global IPv6 with ifconfig en0 inet6 and confirm it is unreachable from outside. Not yet run.

macOS

  • System Settings → Network → Firewall shows on.
  • Remote Login is on and Allow access for lists only your account.
  • Full disk access for remote users is off.

SSH

  • ssh <user>@<mac>.local works from the LAN.
  • ssh <user>@100.x.y.z works over Tailscale from outside the house.
  • From a tailnet device that the grant should reject, the same command fails. This is the check people skip, and it is the one that proves the grant works.

Screen Sharing

  • Connecting to vnc://<mac>.local from the LAN works.
  • Connecting to the Tailscale address on 5900 fails, because the grant allows only tcp:22. Not yet run.

App

  • docker compose ps shows no published host ports.
  • curl http://localhost:3000 from the Mac itself fails. If it succeeds, something is publishing a port.
  • https://app.devtrillo.com loads.
  • docker compose logs tunnel shows the connector registered and the pre-checks passing.

Reboot

  • sudo reboot, then wait without touching the machine.
  • The Mac logs in on its own, Docker Desktop starts, and both containers come back.
  • https://app.devtrillo.com loads again with no intervention. Not yet run. Until this passes, the setup is not finished.

Where this leaves me

The design itself holds up. Administration goes through a private network, the app goes through an outbound tunnel, and there is no listening socket on the public internet for anyone to find in the first place. What I like most about it is how boring the failure mode is: if the Cloudflare connector dies, the app goes offline and stays offline until I fix it. It never fails in the direction of becoming reachable in a way I did not intend, which is the failure mode port forwarding gives you.

What I do not like is the reboot compromise. Trading full disk encryption for unattended availability is a bad trade in most situations, and I only take it because this particular machine holds an app, its images, and nothing else anyone would want. If the Tahoe 26 remote-unlock path can bring the stack all the way back with FileVault left on, I would rather have that, and I will update this post once I have actually tested it. The placeholders above are still placeholders until then, and I will replace them in the same pass that the reboot test passes.

Footnotes

  1. Shodan, a search engine for internet-connected devices and services. ↩

  2. Censys Search, which continuously scans and indexes reachable hosts. ↩

  3. The zero-public-ingress architecture here is adapted from this video, which applies it to a VPS. The macOS-specific parts, and the mistakes in them, are mine. ↩

  4. macOS Tahoe 26 is the current release as of writing. ↩

  5. Tailscale, Install Tailscale on macOS, which recommends the standalone variant. ↩

  6. Tailscale, CLI reference: the App Store build bundles the CLI inside the app, while the standalone build can install a launcher at /usr/local/bin/tailscale. ↩

  7. Apple, About systemsetup. ↩

  8. Apple, If you can’t use systemsetup with certain flags. Apple marks this article as archived, and it was written for Catalina, so confirm the behavior on your own release. ↩

  9. Tailscale, Tailscale SSH, including the note that the server component is only available on Linux and the open source macOS CLI build. ↩ ↩2

  10. Tailscale, Tailnet policy file syntax and grants. ↩

  11. Apple, Turn Screen Sharing on or off. ↩

  12. Apple, TCP and UDP ports used by Apple software products, which is also where Apple states that the application firewall controls access by app rather than by port. ↩ ↩2

  13. Apple, Block connections to your Mac with a firewall. ↩ ↩2

  14. Cloudflare, Tunnel with firewall. ↩

  15. Cloudflare, Create a remotely-managed tunnel and Set up Cloudflare Tunnel. ↩ ↩2

  16. Cloudflare, DNS records for tunnel routes. ↩

  17. Docker, Networking in Compose. ↩

  18. Docker, Compose services reference, on ports and expose. ↩

  19. Docker, Version and name in Compose. ↩

  20. Cloudflare, Tunnel run parameters, covering both TUNNEL_TOKEN and --no-autoupdate. ↩ ↩2

  21. Docker, Start containers automatically. ↩

  22. Docker, Variable interpolation. ↩

  23. Cloudflare, Connectivity pre-checks, added in cloudflared 2026.5.2. ↩

  24. Docker, Docker Desktop settings. ↩

  25. Apple, Automatically log in to your Mac. ↩

  26. Apple, Log in automatically on Mac: “When FileVault is turned on, automatic login is disabled,” and “Automatic login allows anyone to access your Mac simply by restarting it.” ↩ ↩2

  27. Apple, Turn off FileVault on Mac. ↩ ↩2

  28. Apple, What’s new for enterprise in macOS Tahoe 26: “FileVault can now be unlocked over ssh after a restart if Remote Login is enabled and a network connection is available.” ↩

Piwi hands a single letter to the user at a mailbox; a small note reads no noise.

Get the next one in your inbox

One email when a post goes out, with its sketch. Nothing in between, and one link to leave.

Sign in faster next time?

Add a passkey and skip the email link. Your fingerprint, face or device PIN is enough.