Cloudflare Tunnel is a service offered by Cloudflare that allows users to securely expose their web servers and other services to the internet through a secure, encrypted connection.
Normally, when you want to make a web server available on the internet, you would need to configure your network firewall to allow traffic to your server, and then configure your DNS to point to your server’s IP address. This can be a complicated and error-prone process.
With Cloudflare Tunnel, you can create a secure tunnel between your web server and the Cloudflare network. Traffic to your website is then routed through the Cloudflare network, which provides security and performance benefits, such as protection against DDoS attacks and web application firewalls.
Cloudflare Tunnel is especially useful for servers that are behind firewalls or are located on private networks, as it allows them to be securely exposed to the internet without needing to modify the network’s firewall rules or make the server publicly accessible.
Installation :
- Install the Cloudflare command-line tool, known as
cloudflared
, on your local machine or server. You can download the tool from the official Cloudflare website. - Authenticate the
cloudflared
tool with your Cloudflare account. You can use your API key or email and password to do this. - Create a new hostname in your Cloudflare account that you will use to access your application. This can be a subdomain or a new domain that you own or have access to.
- Generate a certificate for your hostname using the
cloudflared
tool. This will create a TLS certificate that is used to encrypt traffic between the Cloudflare network and your application. - Create a configuration file for your tunnel, specifying the hostname and the port that your application is listening on. You can also specify other options, such as custom headers or a list of IP addresses that are allowed to access your application.
- Start the Cloudflare Tunnel by running the
cloudflared tunnel run
command and pointing it to your configuration file. This will create a secure connection between your local machine or server and the Cloudflare network, allowing your application to be accessed via the hostname you specified.
Once your tunnel is set up and running, you can access your application via the hostname you created, and all traffic will be encrypted and proxied through the Cloudflare network, providing additional security and performance benefits.
For more details : Cloudflare Tunnel · Cloudflare Zero Trust docs