Retour aux articles

Hosting Your Apps from a PC or VPS: Coolify & Cloudflare Tunnel

From your laptop to a VPS: how to deploy and expose web applications to the world using Coolify and Cloudflare Tunnel, even behind CGNAT.

Level Sony
Docker Coolify Cloudflare Self-Hosted DevOps Cloud
 Hosting Your Apps from a PC or VPS: Coolify & Cloudflare Tunnel
Table des matières

In my previous article, I described how Coolify structured my VPS deployments. Today, we’re pushing the idea further: can we turn any machine — a laptop, a desktop PC, or a VPS — into a hosting platform accessible from anywhere on the Internet?

The answer is yes. And the Coolify + Cloudflare Tunnel combination is what makes it possible, even in notoriously tricky network setups.


The Hidden Trap: CGNAT

Before we start, there’s a point that most self-hosting guides quietly skip over: CGNAT (Carrier-Grade NAT).

Many ISPs share a single public IP address across multiple subscribers. In practice, even with a perfectly configured port forwarding rule on your router, your services remain unreachable from the outside world.

How to check if you’re affected?

  1. In your router settings, note the IP shown in the WAN / Internet section.
  2. Compare it with the public IP visible on a site like whatsmyip.org.
  3. If the two addresses differ, you’re behind CGNAT.

Typical CGNAT range: 100.64.0.0 → 100.127.255.255

No need to panic — Cloudflare Tunnels are specifically designed to work around this limitation. And Coolify brings the interface and orchestration that turns the whole thing into a proper deployment platform.


The Stack: Your Own Vercel, at Home or on a VPS

The goal: pair Coolify (app management and deployment) with Cloudflare Tunnel (secure internet exposure without port forwarding). The result: a self-hosted alternative to Vercel, Netlify, or Heroku — on your own hardware.

Coolify PaaS


Step 1 — Install Coolify

Installation is a single command, whether you’re working locally or on a remote VPS:

curl -fsSL https://cdn.coollabs.io/coolify/install.sh | sudo bash

This script also handles Docker Engine installation if it’s not already present.

If you’re working on your local PC, run this command directly in your terminal.

If you’re using a VPS, SSH in first:

ssh user@<vps-ip>

then run the install command.

Once installation is complete, open your browser:

Create your admin account. You now have a dashboard capable of deploying Node.js, Next.js, Python, WordPress, or any database directly from your own infrastructure.

Coolify PaaS


Step 2 — Deploy a Demo Project

To validate the setup, let’s deploy a project from a public GitHub repository.

  1. In Coolify, select “Public Repository”.
  2. Paste the repository URL. For this demo: https://github.com/sony-level/Portfolio_Website
  3. Select Docker as the Build Pack, then click Continue.

Coolify PaaS

Before clicking Deploy, check the Network section — this is essential for linking a custom domain later:

FieldValue
Exposed Ports3000
Port Mappings3000:3000

Click Deploy. Once the build completes, Coolify generates a URL in the format:

http://xo0gcogkks04ks4sgkk84oww.<your-ip>.sslip.io

Is this link accessible?

  • Yes (VPS or ISP without CGNAT) → your Vercel alternative is live. Congratulations.
  • No (CGNAT or local machine) → move on to step 3.

In the meantime, your app is still reachable locally. If Coolify runs on http://10.0.0.1:8000/, your app responds at http://10.0.0.1:3000/.

Custom domain without CGNAT

To attach your own domain:

  1. Add a DNS A record pointing to your public IP.
  2. In Coolify, update the Domain field for your application.
  3. Save and redeploy.

Step 3 — Bypass CGNAT with Cloudflare Tunnel

If your public URL remains unreachable, here’s how to expose your services cleanly and securely.

3.1 Install cloudflared

Download and install cloudflared from the official Cloudflare documentation.

3.2 Authenticate your machine

cloudflared tunnel login

A browser window opens to authorize access to your Cloudflare account.

3.3 Create a tunnel

cloudflared tunnel create <TUNNEL_NAME>

This command returns a UUID. Keep it safe — you’ll need it in the following steps.

3.4 Configuration file

In the ~/.cloudflared/ directory, create a config.yml file:

url: http://localhost:8000
tunnel: <YOUR-UUID>
credentials-file: /root/.cloudflared/<YOUR-UUID>.json

3.5 Route a subdomain

Make sure your main domain is already managed in Cloudflare, then:

cloudflared tunnel route dns <UUID-or-NAME> <subdomain.example.com>

3.6 Start the tunnel

cloudflared tunnel run <UUID-or-NAME>

If you manage multiple tunnels, specify the config path:

cloudflared tunnel --config /path/to/config.yml run <NAME>

3.7 Check tunnel status

cloudflared tunnel info

Visit subdomain.example.com: your Coolify dashboard is now accessible from anywhere, over HTTPS, with no open ports.


Step 4 — Expose Your App on Its Own Subdomain

The tunnel currently points to Coolify (port 8000). To route traffic directly to your application (port 3000), add a dedicated route.

Via the Cloudflare dashboard

  1. Go to Networks > Tunnels.
  2. Click your tunnel → Routes → Add a route.
  3. Select Published Application.
  4. Fill in:
    • Subdomain: www
    • Service URL: http://localhost:3000
  5. Click Add route.

Update in Coolify

  1. Open your project → Configuration > General.
  2. Update the Domains field: www.example.com
  3. Save and redeploy.

The Result

Your application — whether running on a recycled old laptop or a €5/month VPS — is now reachable from anywhere in the world at www.example.com, over HTTPS, with no open ports and no complex network configuration.

That’s the promise of Coolify + Cloudflare Tunnel: a complete self-hosting platform, accessible to everyone, regardless of your network setup.

Happy self-hosting!

Commentaires