{"id":4825,"date":"2022-04-11T15:17:26","date_gmt":"2022-04-11T07:17:26","guid":{"rendered":"https:\/\/www.jameseduard.com\/?p=4825"},"modified":"2022-04-11T15:17:26","modified_gmt":"2022-04-11T07:17:26","slug":"how-to-create-free-cloudflare-tunnel","status":"publish","type":"post","link":"https:\/\/www.jameseduard.com\/?p=4825","title":{"rendered":"How to Create Free Cloudflare Tunnel"},"content":{"rendered":"\n\n\n<h3 class=\"wp-block-heading\" id=\"tutorial-scenario\">Tutorial Scenario:<\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li>Signup for a free Cloudflare for Teams.<\/li><li>Install and authenticate cloudflared on a Raspberry Pi 4.<\/li><li>Create a Cloudflare Tunnel.<\/li><li>Configure the Tunnel details.<\/li><li>Create DNS records to route traffic to the Tunnel.<\/li><li>Run and manage the Tunnel.<\/li><li>Add a Zero Trust policy.<\/li><li>Run Tunnel as a service.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-1-signup-for-a-free-cloudflare-for-teams\">Step 1: Signup for a free Cloudflare for Teams:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to&nbsp;<a href=\"https:\/\/dash.cloudflare.com\/sign-up\">Cloudflare for Teams<\/a>&nbsp;and signup for a free account. Cloudflare has a well documented&nbsp;<a href=\"https:\/\/developers.cloudflare.com\/cloudflare-one\/setup\">Get started<\/a>&nbsp;site to walk you through the setup process. For this step, you don\u2019t need to go beyond signing up.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-install-and-authenticate-cloudflared-on-a-raspberry-pi-4\">Step 2: Install and authenticate Cloudflared on a Raspberry Pi 4:<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>First of all, if you\u2019d like to check your device\u2019s architecture, run the following command:<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">uname -a\n<\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Navigate to&nbsp;<a href=\"https:\/\/developers.cloudflare.com\/cloudflare-one\/connections\/connect-apps\/install-and-setup\/installation\">Install Cloudflared<\/a>&nbsp;site to download the proper package for your architecture. In my case, I will install the Cloudflared daemon on my RPI-4, which is an&nbsp;<strong>arm64<\/strong>&nbsp;architecture.<\/li><\/ol>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"arm64-architecture-64-bit-raspberry-pi-4\">arm64 architecture (64-bit Raspberry Pi 4):<\/h5>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo wget -O cloudflared https:\/\/github.com\/cloudflare\/cloudflared\/releases\/latest\/download\/cloudflared-linux-arm64\nsudo mv cloudflared \/usr\/local\/bin\nsudo chmod +x \/usr\/local\/bin\/cloudflared\ncloudflared -v\n<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"amd64-architecture-debianubuntu\">AMD64 architecture (Debian\/Ubuntu):<\/h5>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo wget https:\/\/bin.equinox.io\/c\/VdrWdbjqyF\/cloudflared-stable-linux-amd64.deb\nsudo apt-get install .\/cloudflared-stable-linux-amd64.deb\ncloudflared -v\n<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"armhf-architecture-32-bit-raspberry-pi\">armhf architecture (32-bit Raspberry Pi):<\/h5>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo wget https:\/\/bin.equinox.io\/c\/VdrWdbjqyF\/cloudflared-stable-linux-arm.tgz\ntar -xvzf cloudflared-stable-linux-arm.tgz\nsudo cp .\/cloudflared \/usr\/local\/bin\nsudo chmod +x \/usr\/local\/bin\/cloudflared\ncloudflared -v\n<\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Once we have installed Cloudflared successfully, we will run the following command to authenticate the cloudflared to our Cloudflare account.<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">cloudflared login\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Running the above command will launch the default browser window and prompt you to login to your Cloudflare account. Then, you will be prompted to select a hostname site, which we have create previously in&nbsp;<a href=\"http:\/\/omar2cloud.github.io\/cloudflare\/domain\/domain\/#step-2-signup-for-a-free-account-at-cloudflare\">Part 1: Step 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As soon as you have chosen your hostname, Cloudflare will download a certificate file to authenticate&nbsp;<strong>Cloudflared<\/strong>&nbsp;with Cloudflare\u2019s network.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cert.pem gives Cloudflared the capabilities to create tunnels and modify DNS records in the account. Once you have created a named Tunnel, you no longer need the cert.pem file to run that Tunnel and connect it to Cloudflare\u2019s network. However, hte cert.pem file is still required to create additional Tunnels, list existing tunnels, manage DNS records, or delete Tunnels.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/6.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/6.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/7.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/7.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/8.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/8.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/9.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/9.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once authorization is completed successfully, your cert.pem will be download to the default directory as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/10.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/10.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re running a headless server (no monitor or keyboard), you could copy the authentication URL and paste it in a browser manually.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The credentials file contains a secret scoped to the specific Tunnel UUID which establishes a connection from cloudflared to Cloudflare\u2019s network. cloudflared operates like a client and establishes a TLS connection from your infrastructure to Cloudflare\u2019s edge.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-3-create-a-cloudflare-tunnel\">Step 3: Create a Cloudflare Tunnel:<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>Now, we are ready to create a&nbsp;<strong>Cloudflare Tunnel<\/strong>&nbsp;that will connect&nbsp;<strong>Cloudflared<\/strong>&nbsp;to Cloudflare\u2019s edge. Utilizing the following command will create a Tunnel with tht name and generate an ID credentials file for it.<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Prior to creating the Tunnel, you may need to exit the Command Line (CL). Next, let create the Tunnel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Note: replace &lt;NAME&gt; with any name of your choosing for the Tunnel.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">cloudflared tunnel create &lt;NAME>\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once the Tunnel is created, a credential file is generated. It\u2019s a JSON file that has the Universally Unique Identifier (UUID) assigned for the Tunnel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Note: although the Tunnel is created, the connection is not established yet.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/13.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/13.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-4-configure-the-tunnel-details\">Step 4: Configure the Tunnel details:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Although we can configure the Tunnel run in an add hoc mode, we will go over creating a configuring the Tunnel to automatically run it as a service.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cloudflare utilizes a&nbsp;<strong>configuration file<\/strong>&nbsp;to determine how to route traffic. The configuration file contains keys and values, which is written in&nbsp;<strong>YAML<\/strong>&nbsp;syntax. You may need to modify the following keys and values to meet your configuration file requirements:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Keys<\/th><th>Values<\/th><\/tr><\/thead><tbody><tr><td>tunnel<\/td><td>Tunnel name or Tunnel UUID<\/td><\/tr><tr><td>credentials-file<\/td><td>location of credentials file (JSON)<\/td><\/tr><tr><td>hostname<\/td><td>subdomain.hostname.xxx (example, test.example.com)<\/td><\/tr><tr><td>service<\/td><td>url to local application &#8211; http:\/\/localhost:8000<\/td><\/tr><tr><td>service<\/td><td>http_status:404<\/td><\/tr><tr><td>port of your app<\/td><td>80<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">By default, on Linux systems, Tunnel expects to find the configuration file in&nbsp;<em>~\/.cloudflared<\/em>,&nbsp;<em>\/etc\/cloudflared<\/em>&nbsp;and&nbsp;<em>\/usr\/local\/etc\/cloudflared<\/em>&nbsp;in that order. Let\u2019s create our config file and save in the default expected directory for this tutorial.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo nano ~\/.cloudflared\/config.yml\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Or,<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo nano home\/&lt;username>\/.cloudflared\/config.yml\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/16.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/16.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then, we will paste our keys and values as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">tunnel: 1082b601-bce9-45e4-b6ae-f19020e7d071\ncredentials-file: \/root\/.cloudflared\/1082b601-bce9-45e4-b6ae-f19020e7d071.json\n\ningress:\n  - hostname: test.mytunnel.ml\n    service: http:\/\/localhost:80\n  - service: http_status:404\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/16_1.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/16_1.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you don\u2019t have any application ready to test the Tunnel, I\u2019d suggest installing NGINX web server and port mapping it to port 80 as I\u2019ve done in the configuration file.&nbsp;Expand me&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s make sure that we have all files in this directory:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">ls -al\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we have configured all required files to run the Tunnel in the default directory.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/17.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/17.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;Expand me&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-5-create-dns-records-to-route-traffic-to-the-tunnel\">Step 5: Create DNS records to route traffic to the Tunnel:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cloudflare can route traffic to our Tunnel connection using a DNS record or a loud balancer. We will configure a DNS CNAME record to point to our Tunnel subdomain. There are two ways to acheive this mission:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A.&nbsp;<strong>Manually:<\/strong>&nbsp;navigate to the DNS tab on Cloudflare Dashboard, create a new CNAME record and add your subdomain of your Tunnel as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Type: CNAME<\/li><li>Name: any subdomain name of your choosing.<\/li><li>Target: consists of two parts: &lt;<em>UUID<\/em>&gt; and &lt;<em>cfargotunnel.com<\/em>&gt; such as,&nbsp;<strong>&lt;<em>UUID.cfargotunnel.com<\/em>&gt;<\/strong><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">B.&nbsp;<strong>Programmatically:<\/strong>&nbsp;run the following command from the command line. This command will generate a CNAME record that points to the subdomain of a specific Tunnel. The result is the same as creating a CNAME record from the dashboard as shown in step A.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">cloudflared tunnel route dns &lt;UUID or NAME> test.example.com\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/18.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/18.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Note: unlike the previous Argo Tunnel architecture, this DNS record will not be deleted if the Tunnel disconnects.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-6-run-and-manage-the-tunnel\">Step 6: Run and manage the Tunnel:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<strong>run<\/strong>&nbsp;command will connect cloudflared to Cloudflare\u2019s edge network using the configuration created in step 4. We will not specify a configuration file location so Cloudflared retrieves it from the default location, which is&nbsp;<em>~\/.cloudflared\/config.yml<\/em><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">cloudflared tunnel run &lt;UUID> or &lt;Tunnel Name>\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/19.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/19.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If the config.yml file is not placed in the default directory, we need to pinpoint to its location to run the Tunnel:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">cloudflared tunnel --config path\/config.yml run &lt;NAME> or &lt;UUID>\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can review the list of Tunnels we have created by running the following command:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"cloudflared-commands\">Cloudflared Commands:<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Functions<\/th><th>Commands<\/th><\/tr><\/thead><tbody><tr><td>Create a Tunnel<\/td><td>cloudflared tunnel run &lt;<em>NAME<\/em>&gt;<\/td><\/tr><tr><td>List Tunnels<\/td><td>cloudflared tunnel list<\/td><\/tr><tr><td>Stop Tunnel<\/td><td>cloudflared tunnel stop &lt;<em>NAME<\/em>&gt;<\/td><\/tr><tr><td>Restart Tunnel<\/td><td>cloudflared tunnel restart &lt;<em>NAME<\/em>&gt;<\/td><\/tr><tr><td>Delete Tunnel<\/td><td>cloudflared tunnel delete &lt;<em>NAME<\/em>&gt;<\/td><\/tr><tr><td>Force Delete Tunnel<\/td><td>cloudflared tunnel delete -f &lt;<em>NAME<\/em>&gt;<\/td><\/tr><tr><td>Show each Cloudflared info<\/td><td>cloudflared tunnel info &lt;<em>NAME<\/em>&gt;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Stopping Cloudflared will not delete the Tunnel or the DNS record created. Although Tunnel deletes DNS records after 24-48 hours of a Tunnel being unregistered, it does not delete TLS certificates on your behalf once the Tunnel is shut down. If you want to clean up a Tunnel you\u2019ve shut down, you can delete DNS records in the DNS editor and revoke TLS certificates in the Origin Certificates section of the SSL\/TLS tab of the Cloudflare dashboard.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>To update Cloudflared<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo cloudflared update\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><em>To uninstall Cloudflared<\/em><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo cloudflared service uninstall \n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-7-add-a-zero-trust-policy\">Step 7: Add a Zero Trust policy:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we are ready to head back to Teams dashboard to configure our application and create a Zero Trust Policy.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>On Teams dashboard, navigate to the Application tab and click on Add an application.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/10.JPG?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/10.JPG?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Select Self-hosted.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/11.JPG?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/11.JPG?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Choose an application name, Session Duration, subdomain and Application domain. Then, click on Next.<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Notice that the Tunnel duration ranges from 15 mins to 1 month.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/13.JPG?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/13.JPG?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>Add a name to the rule and select&nbsp;<strong>Bypass<\/strong>&nbsp;as a Rule action. On Configure a rule, include Everyone. This rule allows everyone to view our NGINX site at&nbsp;<strong>test.mytunnel.ml<\/strong><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/30.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/30.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li>In the Advanced settings, enable automatic cloudflared authentication and browser rendering.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/31.png?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/31.png?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/32.JPG?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/32.JPG?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, our application is now available in Cloudflare Access and is part of our Application list. We can navigate to a browser and type in our url&nbsp;<strong>test.MyTunnel.ml<\/strong>&nbsp;and if our Tunnel is established correctly, we shall see our NGINX web server running as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/33.JPG?classes=shadow\"><img decoding=\"async\" src=\"https:\/\/omar2cloud.github.io\/images\/CloudFlare\/Cloudflared\/33.JPG?classes=shadow\" alt=\"cloudflare\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-8-run-tunnel-as-a-service\">Step 8: Run Tunnel as a service:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By running the following command, the Tunnel can be installed as a system service which allows the Tunnel to run at boot automatically as launch daemon. By default, the Tunnel expects to find the configuration file in the default directory,&nbsp;<em>~\/.cloudflared\/config.yml<\/em>&nbsp;but to run Tunnel as a service, we might need to move the config.yml file in&nbsp;<em>~\/etc\/cloudflared\/<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can employ the move&nbsp;<strong>mv<\/strong>&nbsp;command to do the job:&nbsp;<em>mv &lt;path\/config.yml&gt; to &lt;\/etc\/cloudflared\/<\/em>&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The below command is in my case with my RPI-4 and how I moved the config file to \/etc\/cloudflared\/<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo mv \/home\/p2\/.cloudflared\/config.yml \/etc\/cloudflared\/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we are ready to run Tunnel as a service utilizing the command below:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">sudo cloudflared service install \n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We have successfully established a secure Cloudflare Tunnel that links our locally hosted NGINX web server to Cloudflare\u2019s network without requiring any public IP address, port-forwarding or punching through a firewall. We have also configured the Tunnel as a service to start at boot, and now we have our NGINX web server associated and accessible via our domain name, test.MyTunnel.ml<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tutorial Scenario: Signup for a free Cloudflare for Teams. Install and authenticate cloudflared on a Raspberry Pi 4. Create a Cloudflare Tunnel. Configure the Tunnel details. Create DNS records to route traffic to the Tunnel. Run and manage the Tunnel. Add a Zero Trust policy. Run Tunnel as a service. Step 1: Signup for a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[825,52,47],"tags":[881,747,774],"class_list":["post-4825","post","type-post","status-publish","format-standard","hentry","category-cloudflare","category-devops","category-how-tos","tag-argo","tag-cloudflare","tag-tunnel"],"_links":{"self":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/posts\/4825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4825"}],"version-history":[{"count":0,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/posts\/4825\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}