The original post: /r/selfhosted by /u/Tylerebowers on 2024-10-14 00:24:21.

All praise to Cloudflare for making Tunnels free, I am now hosting my two websites behind a CGNAT connection for zero extra cost. And it actually seems a bit faster (though I am not sure why this is).

Here is how to use cloudflare tunnels:

  1. Login -> dashboard -> Zero Trust -> Networks -> Create a tunnel.
  2. I am using “Cloudflared” tunnel type so it is outbound only, however there is also WARP for linux only. Not sure which is better.
  3. Name it and follow the instructiuons to install the Cloudflared service on your webserver.
  4. If you already have A/AAAA/CNAME DNS entries that point to a public IP then you will need to remove them.
  5. Once you make it you can edit the settings for Public Hostnames, add the website domains and point them to your localhost & port. In my case I am using 127.0.0.1:80 and port 81 for my other website.
  6. You will also have to configure your webserver to listen/bind to the localhost IP & respective ports.

And done! Your website domain now points to a cloudflare tunnel: <UUID>.cfargotunnel.com which points to your webserver’s localhost:port.

Cloudflares Terms of Service do not allow that many other services to be hosted through these tunnels so consider reading them if you are to host anything else.

There are other services that you can use to acomplish the same thing like tailscale, wireguard, etc. Some are also free but most are paid. I am using tunnels simply becuase I already use cloudflare for DNS & as a registrar.