# Publishing your internal ports to the Internet with Cloudflare Tunnel

Setting up a home server means exposing your private services to the internet. In the past, the most popular way by port-forwarding through the router, which is quite risky. Nowadays, most ISPs block access to router settings and don't allow port-forwarding.

An alternative is to tunnel your local port through service providers that expose your service to the internet. These tunnel providers add the necessary security, making it safer than port-forwarding. However, while slightly more secure, this is not a very secure option overall. If security is important to you, consider using a VPN instead.

## Cloudflare Tunnels

To use Cloudflare Tunnels, there are some prerequisites:

* Cloudflare account
    
* A domain
    

You have to add your domain to the Cloudflare account first. Follow these steps to add the tunnel:

* Go to Zero Trust in the sidebar - You will be navigated to [one.dash.cloudflare](https://one.dash.cloudflare.com)
    
* Go to Networks
    
* Go to Tunnel
    
* Add Tunnel
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720278851319/41fcae78-00bf-49a6-9ccd-782cc64d0ef8.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720278898955/431a7d11-4d5b-43e9-ad42-46cbf97679e4.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720279008601/17191cab-7224-4484-8cdc-4f3582903bd7.png align="center")

Now run the below command in your terminal. *Disclaimer: Doing this will spawn a daemon with root permission, which can stay as a middleman between you and the internet. So do this if you trust Cloudflare.* Again, I advertise using private VPN over this method.

After the command runs successfully, basic setup for the tunnel is completed. Now we define which port to tunnel and to what domain.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720279380132/3719952c-a637-4529-99c5-e58ecee136cc.png align="center")

After saving the settings. We will be able to access the port 80 of our local machine via `testy.buddhag.com.np`. This is the entry point to HTTP request in my machine, which is running nginx in that port.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720279497510/56af4f1d-8adb-45b8-8781-2c7a4221ce99.png align="center")

Congratulations, you have successfully tunneled your local port to the internet.
