<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MD.AL-AMIN</title>
    <description>The latest articles on DEV Community by MD.AL-AMIN (@alamin899).</description>
    <link>https://dev.to/alamin899</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1290611%2F9a6f1d9b-68ec-4417-b905-3b2ff6b4d5fb.jpeg</url>
      <title>DEV Community: MD.AL-AMIN</title>
      <link>https://dev.to/alamin899</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alamin899"/>
    <language>en</language>
    <item>
      <title>Local machine as a web server without public IP using Cloudflare tunnel(part-1)</title>
      <dc:creator>MD.AL-AMIN</dc:creator>
      <pubDate>Thu, 22 Feb 2024 10:20:48 +0000</pubDate>
      <link>https://dev.to/alamin899/local-machine-as-a-web-server-without-public-ip-using-cloudflare-tunnel-1ec2</link>
      <guid>https://dev.to/alamin899/local-machine-as-a-web-server-without-public-ip-using-cloudflare-tunnel-1ec2</guid>
      <description>&lt;p&gt;we can use our local machine as a public webserver using Cloudflare tunnel. you do not need any public IP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PC or laptop&lt;/li&gt;
&lt;li&gt;you need a public domain(possible without a domain)&lt;/li&gt;
&lt;li&gt;Cloudflare account&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/" rel="noopener noreferrer"&gt;&lt;u&gt;&lt;strong&gt;Cloudflare Tunnel&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;&lt;br&gt;
Cloudflare Tunnel provides you with a secure way to connect your resources to Cloudflare without a publicly routable IP address. With Tunnel, you do not send traffic to an external IP — instead, a lightweight daemon in your infrastructure (‘cloudflared’) creates outbound-only connections to Cloudflare’s global network. Cloudflare Tunnel can connect HTTP web servers, SSH servers, remote desktops, and other protocols safely to Cloudflare&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;strong&gt;Step-1(Install OS)&lt;/strong&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;I use Ubuntu OS in my daily work. So I installed an Ubuntu server on my laptop which I will use as a server machine. You can also use another OS (ubuntu-desktop, Mac OS, windows). after installation, you have to ensure that you connect to the internet, after setup internet your machine is ready to serve as web-server.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;&lt;strong&gt;Step-2(Connect your domain with cloudflare)&lt;/strong&gt;&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Create a Cloudflare account. after sign up then login in Cloudflare account. After login, you will redirect to the dashboard .From dashboard click &lt;u&gt;add a site&lt;/u&gt; button. then enter your domain and submit then you will see name-server ,this name-serve add to your domain registered dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxhv8rxegon8hjg7ehtka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxhv8rxegon8hjg7ehtka.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Congratulations your domain and cloudflare are connected now.&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/#1-download-and-install-cloudflared" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;u&gt;Step-3(Install cloudflare in your linux machine)&lt;/u&gt;&lt;/strong&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Add Cloudflare’s package signing key:&lt;/u&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg &amp;gt;/dev/null


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Add Cloudflare’s apt repo to your apt repositories:&lt;/u&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflared.list


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Update repositories and install cloudflared:&lt;/u&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install cloudflared


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After successfully install Cloudflare check&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

cloudflared -v


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Installing process for other OS - &lt;a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/#1-download-and-install-cloudflared" rel="noopener noreferrer"&gt;Download And Install&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;&lt;a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/#2-authenticate-cloudflared" rel="noopener noreferrer"&gt;Step-4(Create Tunnel and use)&lt;/a&gt;&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Authenticate cloudflared&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo cloudflared tunnel login


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After this command you will be redirected to your Cloudflare account otherwise you will get a link, then you will use this link after you will see list of domain which you attach on your cloudflare account . i selected my domain &lt;code&gt;iamalamin.com&lt;/code&gt; .&lt;br&gt;
after selected youru domain it will create &lt;code&gt;cert.pem&lt;/code&gt; file to your machine &lt;code&gt;/root/.cloudflared/&lt;/code&gt; directorey&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.  Create cloudflare tunnel&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo cloudflared tunnel create &amp;lt;NAME&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;after this command you will get a tunnel.this tunnel has &lt;code&gt;&amp;lt;Tunnel-UUID&amp;gt;&lt;/code&gt; which is store in &lt;code&gt;/root/.cloudflared/&lt;/code&gt; directory with &lt;code&gt;&amp;lt;Tunnel-UUID&amp;gt;.json&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo cloudflared tunnel list


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;show tunnel list in your machine&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Create configure file for my tunnel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In your &lt;code&gt;/root/.cloudflared&lt;/code&gt; directory, create a &lt;code&gt;config.yml&lt;/code&gt; file using any text editor. This file will configure the tunnel to route traffic from a given origin to the hostname of your choice.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

tunnel: &amp;lt;Tunnel-UUID&amp;gt;
credentials-file: /root/.cloudflared/&amp;lt;Tunnel-UUID&amp;gt;.json

ingress:
  - hostname: example-app.com
    service: http://localhost:3000
    originRequest:
      noTLSVerify: true

  - service: http_status:404


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here service: &lt;code&gt;http://localhost:3000&lt;/code&gt; this is your local application running url.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Start routing traffic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now assign a CNAME record that points traffic to your tunnel subdomain:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo cloudflared tunnel route dns &amp;lt;Tunnel-UUID&amp;gt; &amp;lt;your-domain-name&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After this command a &lt;code&gt;CNAME&lt;/code&gt; record will be created in your Cloudflare account domain dashboard.When I visited Cloudflare dashboard's &lt;code&gt;Websites &amp;gt; your-domain.com &amp;gt; DNS &amp;gt; Records&lt;/code&gt; I saw that a new &lt;code&gt;CNAME&lt;/code&gt; record is added in my domain's DNS record. This was added by the command I run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypsk6iiwzqgau2cwsbm0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypsk6iiwzqgau2cwsbm0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Run the tunnel&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo cloudflared tunnel run &amp;lt;Tunnel-UUID or NAME&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You need to always run this command to access your application using this tunnel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.  Run Cloudflared as a service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To always run your Cloudflare you can use Cloudflare service on your machine.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo cloudflared service install
sudo systemctl start cloudflared
sudo systemctl status cloudflared


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Now your application will run from your local machine publicly using cloudflare tunnel&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>cloudflare</category>
      <category>webserver</category>
      <category>publicwebserver</category>
      <category>localmachinewebserver</category>
    </item>
    <item>
      <title>How Cloudflare tunnel work(part-2)</title>
      <dc:creator>MD.AL-AMIN</dc:creator>
      <pubDate>Wed, 21 Feb 2024 16:58:50 +0000</pubDate>
      <link>https://dev.to/alamin899/how-cloudflare-tunnel-work-18d</link>
      <guid>https://dev.to/alamin899/how-cloudflare-tunnel-work-18d</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cloudflare Architecture&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2jpz10msum7ud3wa6bd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2jpz10msum7ud3wa6bd.png" alt="Image description" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cloudflare Tunneling, formerly known as Argo Tunnel, involves several steps and technologies working together to securely expose your local services to the internet. Here's a step-by-step explanation of the internal process and the technologies involved:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare Tunnel Daemon (Cloudflared):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cloudflared is the client-side software that runs on your local machine. It's responsible for creating and managing the encrypted connection between your machine and Cloudflare's edge network.&lt;br&gt;
Cloudflared is built using Go programming language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TLS Handshake:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When Cloudflared starts, it initiates a TLS handshake with Cloudflare's edge servers. This handshake establishes a secure, encrypted communication channel using Transport Layer Security (TLS) protocol.&lt;br&gt;
TLS ensures that the data exchanged between Cloudflared and Cloudflare's edge is encrypted and secure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WebSocket Connection:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After the TLS handshake is completed, Cloudflared establishes a WebSocket connection with Cloudflare's edge.&lt;br&gt;
WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection. It allows for efficient, bi-directional communication between Cloudflared and Cloudflare's edge servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare Edge Network:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cloudflare's edge network consists of data centers distributed globally. Each data center acts as a point of presence (PoP) where incoming traffic is processed and optimized.&lt;br&gt;
Cloudflare's edge servers handle incoming requests from users and route them to the appropriate destination, including the Cloudflare Tunnel endpoints.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Tunnel Endpoint:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Cloudflare assigns a unique tunnel endpoint to each Cloudflared instance running on your local machine. This endpoint acts as the entry point for incoming traffic destined for your local services.&lt;br&gt;
The tunnel endpoint is a domain name or a subdomain hosted by Cloudflare.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Discovery:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You configure Cloudflared to specify which local services you want to expose to the internet. This can include web servers, APIs, or any other TCP-based service running on your machine.&lt;br&gt;
Cloudflared dynamically discovers these services and establishes connections to them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encrypted Tunnel:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the WebSocket connection is established and services are discovered, Cloudflared creates an encrypted tunnel between your machine and Cloudflare's edge network.&lt;br&gt;
This tunnel securely forwards incoming traffic from Cloudflare's edge to the specified local services running on your machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS Configuration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You configure DNS records on Cloudflare's platform to point to the tunnel endpoint assigned to your Cloudflared instance.&lt;br&gt;
This ensures that incoming traffic to your domain is directed through Cloudflare's network to your local machine via the established tunnel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traffic Routing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user accesses your domain, their request is routed through Cloudflare's global network to the nearest data center.&lt;br&gt;
From there, it's forwarded through the established tunnel to your local machine where your service is hosted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security Features:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cloudflare provides various security features such as DDoS protection, Web Application Firewall (WAF), and rate limiting to safeguard your exposed services from malicious attacks and unauthorized access.&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>tunnel</category>
      <category>localmachineaswebserver</category>
    </item>
  </channel>
</rss>
