Forge Fate
Backend & Infrastructure

Putting a Home Mac on Public HTTPS Without Port Forwarding: Four Checks on Cloudflare Tunnel's First Boot

6 min read

The first goal in Part 1 was to see one "hello" line from the Spring API at https://forge-fate.com. That meant connecting the public domain to Docker containers on my home Mac.

The setup had four containers and a Cloudflare tunnel. Getting there meant sorting out a connector installed on the host, addresses inside containers, DNS, and a certificate that was already working.

Starting point: four containers and a tunnel token

The whole setup lives in one docker compose file: PostgreSQL, the Spring API (blog-api), the Next.js web app (blog-web), and the tunnel connector cloudflared. The cloudflared service runs with the token from the dashboard.

This is the configuration from the first boot in June 2026. The image tag records the version used then; it is not a version recommendation for a new installation today.

infra/docker-compose.yml (June 2026 excerpt)yaml
  cloudflared:    image: cloudflare/cloudflared:2024.12.2    command: tunnel --no-autoupdate run --token ${TUNNEL_TOKEN}

This tunnel was managed through the dashboard, so I did not use a local config.yml. Which domain goes to which service is stored in the Cloudflare dashboard, and cloudflared fetches that configuration using the token. The token lives only in infra/.env, which never goes into Git.

1. Two connectors on the same tunnel

When you create a tunnel, the dashboard shows an install command of the form cloudflared service install <token>. Running it registers cloudflared as a system service on the Mac. While moving to the production Mac, I had already run that command once.

But this blog runs cloudflared as a Docker container. So I ended up with two connectors on the same tunnel.

Preparing diagram.

Diagram source
flowchart TB
  CF[Cloudflare edge] --> H[cloudflared installed on the host]
  CF --> C[cloudflared container]
  H -.->|Can't resolve blog-web| X[Connection fails]
  C -->|Docker internal network| W[blog-web]

The problem was the host-side connector. The target registered in the dashboard was http://blog-web:3000, and the name blog-web only resolves inside Docker's internal network. The cloudflared running on the host could not find it, so any request routed to it was bound to fail.

The assumption of a fifty-fifty split

My notes said that half the requests would go to the host and fail, but they contained no measurement of the failure rate. The official documentation does not describe a fifty-fifty split either. When several connectors (replicas) serve one tunnel, Cloudflare sends each request to the geographically closest one. If that connection fails, it retries with another replica, but there is no guarantee which one gets picked, and there is no round-robin style steering. [S1]

Having both connectors on the same Mac does not establish how requests are divided. The issue I could identify was that the host connector could not resolve the target service name. The retry behavior above concerns a failed connection from Cloudflare to a connector; it does not guarantee recovery when the connector cannot reach the origin service.

I removed the host service and kept only the container connector.

bash
sudo cloudflared service uninstall

The dashboard command installs a connector on the host. In this setup, the container connects to the target service, so I only needed the token.

2. Inside a container, localhost is that container

I entered http://blog-web:3000 as the Service URL in the dashboard. The notes explain how that address differs from localhost:3000. They do not contain a log showing that I entered the wrong value and observed a failure.

But cloudflared runs inside a container, and inside a container localhost means that container itself. Nothing listens on port 3000 in the cloudflared container, so entering localhost:3000 gets you a refused connection.

Preparing diagram.

Diagram source
flowchart TB
  subgraph N[Docker internal network]
    C[cloudflared container] -->|http://blog-web:3000| W[blog-web container]
    C -.->|localhost:3000| L[The cloudflared container itself · nothing on port 3000]
  end

Docker Compose lets services on the same network find each other by service name. [S3] The address to use in this setup was http://blog-web:3000.

Running on the host changes the address

If cloudflared had been installed on the host, localhost:3000 would actually have been correct, because the compose file published the web port to 127.0.0.1:3000 on the host.

Where cloudflared runsTarget addressWhy
Docker containerhttp://blog-web:3000Resolves the service name on the shared internal network
Host servicehttp://localhost:3000Reaches the port published on the host

3. The tunnel existed, but the domain didn't respond

I had created the tunnel and pasted in the token, but https://forge-fate.com would not open. I started with DNS.

text
$ nslookup forge-fate.com 1.1.1.1*** Can't find forge-fate.com: No answer

The domain's nameservers were already delegated to Cloudflare, yet the root domain had no records at all.

A running tunnel and the decision about which domain's traffic goes into it turned out to be separate steps. For a public domain to reach a tunnel, its CNAME record has to point at the tunnel's own address (<UUID>.cfargotunnel.com). [S2] Adding a published application route in the dashboard can create the DNS record as well. It is also possible to add the DNS record manually.

These were the menu labels and values I used in June 2026:

  1. Networking → Tunnels → the tunnel → Routes tab
  2. Add route → Published application
  3. Leave the subdomain empty (root), domain forge-fate.com, type HTTP, target http://blog-web:3000

After saving, Cloudflare created a proxied CNAME record, and only then did DNS start answering.

The plan I had written before starting said "Public Hostnames tab → Add a public hostname". The actual dashboard had no such menu. The same feature had become "Routes → Add route → Published application", with the same fields to fill in. If menu names in screenshots or blog posts (this one included) don't match, go by what the current dashboard says.

4. No separate certificate setup was needed

Once the site opened, I checked the certificate issuer. HTTPS worked without a separate Let's Encrypt setup.

text
$ openssl s_client -connect forge-fate.com:443 ... | openssl x509 -issuer ...issuer = Google Trust Services (CN=WE1)

Cloudflare's Universal SSL handles certificate issuance, installation, and renewal. [S4] The certificate authority in the output was Google Trust Services. The http:// target belongs to the internal segment after the tunnel.

SegmentEncryption
Browser ↔ Cloudflare edgeHTTPS with the Universal SSL certificate
Cloudflare edge ↔ home MacEncrypted tunnel that cloudflared opened outward
cloudflared ↔ blog-webPlain HTTP, but only inside Docker's internal network on the Mac

Along this public request path, the segments crossing the internet are encrypted, and the plain HTTP segment stays inside the Mac.

Final checks

After removing the host connector and setting the target address and DNS, I checked the path from the inside out. The certificate needed only a status check, not a separate setup.

CheckHowResult
Containers updocker compose psAll 4 running
Tunnel connectedcloudflared logs4 × Registered tunnel connection
API aloneCall /api/hello from the host{"message":"hello from blog-api"}
Web → API over the internal networkCall the local web port on the hostResponse includes hello from blog-api
Public URLcurl https://forge-fate.comResponse includes hello from blog-api
Certificateopenssl s_clientGoogle Trust Services certificate provided through Universal SSL

The four connections in the logs are for redundancy. By default cloudflared opens four outbound connections spread across at least two data centers. [S1] That day's record shows connections to Seoul edge locations (icn01, icn05, icn06).

I checked from the inside out to narrow things down if something failed. If the API call alone fails, there's no point looking at the tunnel. If the internal call works but the public URL doesn't, the tunnel, DNS, edge configuration, and TLS are among the next things to check.

There were later incidents in which tunnel connectivity kept the site from opening. In July, it stopped after an unexplained termination signal, and I only noticed nine hours later. In September, the whole site went down with HTTP 530; rolling back cloudflared did not restore service, and recovery followed a Docker Desktop restart. Part 5 covers the September recovery and compares it with the July record.

The next post is about the database: the day ddl-auto=update broke on a single NOT NULL foreign key, and why I moved to Flyway.

Sources

About these records

This post is based on the work notes and command output I recorded on June 27, 2026, when I first put this blog on its public domain. Cloudflare dashboard menu names may have changed since then. I rechecked how things work against the official Cloudflare and Docker documentation, and I leave out tokens and tunnel IDs.

Report an error or share feedback

Open a draft with this article’s title and URL. Review the message and recipient before sending.

To: [email protected]

Open email draft

If no email app opens, copy these details into your usual email service.

Contact information