Expose localhost to the internet
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 edge. Cloudflare Tunnel
can connect HTTP web servers, SSH servers, remote desktops, and other
protocols safely to Cloudflare. This way, your origins can serve
traffic through Cloudflare without being vulnerable to attacks that bypass
Cloudflare.
Source Cloudflared |
How it works
Cloudflared establishes outbound connections (tunnels) between your resources and the Cloudflare edge. Tunnels are persistent
objects that route traffic to DNS records. Within the same
tunnel, you can run as many cloudflared processes
(connectors) as needed. These processes will establish connections to
the Cloudflare edge and send traffic to the nearest
Cloudflare data center.
Here we can use cloud tunnel with 2 methods and the first one is installed the cloud tunnel in your system and other one is through binary method.
Cloud Tunnel
First of all let's see how we can install it and use it, first of all
we have copied its deb file. After this download in your terminal,
for this you will use this command.
sudo wget
https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb [sudo] password for hackerboy: --2022-02-19 17:26:46-- https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb Resolving github.com (github.com)... 13.234.210.38 Connecting to github.com (github.com)|13.234.210.38|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://github.com/cloudflare/cloudflared/releases/download/2022.2.1/cloudflared-linux-amd64.deb [following] --2022-02-19 17:26:52-- https://github.com/cloudflare/cloudflared/releases/download/2022.2.1/cloudflared-linux-amd64.deb Reusing existing connection to github.com:443. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/106867604/0148e327-5f0b-408f-adbd-cb69457d2d88?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220219T115511Z&X-Amz-Expires=300&X-Amz-Signature=c3979a7f855e94f233b6bd12147c08771df2b29c3505d38cba991ce645d4a6a4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=106867604&response-content-disposition=attachment%3B%20filename%3Dcloudflared-linux-amd64.deb&response-content-type=application%2Foctet-stream [following] --2022-02-19 17:26:53-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/106867604/0148e327-5f0b-408f-adbd-cb69457d2d88?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220219T115511Z&X-Amz-Expires=300&X-Amz-Signature=c3979a7f855e94f233b6bd12147c08771df2b29c3505d38cba991ce645d4a6a4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=106867604&response-content-disposition=attachment%3B%20filename%3Dcloudflared-linux-amd64.deb&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.110.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 14623558 (14M) [application/octet-stream] Saving to: ‘cloudflared-linux-amd64.deb’ cloudflared-linux-amd64.deb 100%[====================================================================================================>] 13.95M 2.73MB/s in 8.3s 2022-02-19 17:27:03 (1.68 MB/s) - ‘cloudflared-linux-amd64.deb’ saved [14623558/14623558] ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$
This package is about 14 MB, so after that we will install this
downloaded package.
Download Here - Click Here
Lets see how to install it after download deb file, you can use this command for installation -
sudo dpkg -i cloudflared-linux-amd64.deb
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo dpkg -i cloudflared-linux-amd64.deb Selecting previously unselected package cloudflared. (Reading database ... 431738 files and directories currently installed.) Preparing to unpack cloudflared-linux-amd64.deb ... Unpacking cloudflared (2022.2.1) ... Setting up cloudflared (2022.2.1) ... Processing triggers for kali-menu (2021.4.2) ... Processing triggers for man-db (2.9.4-2) ... ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$
After installation, you can run it from anywhere on your system. So
for this you have to use this command
Cloudflared
But before that you have to enable Apache webserver service on your
system.
sudo service apache2 start
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo service apache2 status [sudo] password for hackerboy: ○ apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: https://httpd.apache.org/docs/2.4/ ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo service apache2 start 3 ⨯ ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo service apache2 status ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2022-02-19 18:56:08 IST; 1min 8s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 4694 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 4705 (apache2) Tasks: 10 (limit: 4366) Memory: 32.6M CPU: 488ms CGroup: /system.slice/apache2.service ├─4705 /usr/sbin/apache2 -k start ├─4707 /usr/sbin/apache2 -k start ├─4708 /usr/sbin/apache2 -k start ├─4709 /usr/sbin/apache2 -k start ├─4710 /usr/sbin/apache2 -k start ├─4711 /usr/sbin/apache2 -k start ├─4712 /usr/sbin/apache2 -k start ├─4744 /usr/sbin/apache2 -k start ├─4759 /usr/sbin/apache2 -k start └─4760 /usr/sbin/apache2 -k start Feb 19 18:56:07 KumarAtulJaiswal systemd[1]: Starting The Apache HTTP Server... Feb 19 18:56:08 KumarAtulJaiswal apachectl[4704]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive > Feb 19 18:56:08 KumarAtulJaiswal systemd[1]: Started The Apache HTTP Server. ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$
Let's see the demo that we can open our webpage by sitting
anywhere from the internet on our local webserver.
Here I
have made a webpage on my system's localhost, so as you can see
Here you can type the URL of your localhost or you
can also write the IP address or if you web page is running on any
particular port then you can use this way.
- localhost
- 127.0.0.1
- localhost:4444
You can use this command -
sudo cloudflared --url localhost
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo cloudflared --url localhost 130 ⨯ [sudo] password for hackerboy: 2022-02-19T13:25:39Z INF Thank you for trying Cloudflare Tunnel. Doing so, without a Cloudflare account, is a quick way to experiment and try it out. However, be aware that these account-less Tunnels have no uptime guarantee. If you intend to use Tunnels in production you should use a pre-created named tunnel by following: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps 2022-02-19T13:25:39Z INF Requesting new quick Tunnel on trycloudflare.com... 2022-02-19T13:25:43Z INF +--------------------------------------------------------------------------------------------+ 2022-02-19T13:25:43Z INF | Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): | 2022-02-19T13:25:43Z INF | https://justify-caribbean-surveillance-align.trycloudflare.com | 2022-02-19T13:25:43Z INF +--------------------------------------------------------------------------------------------+ 2022-02-19T13:25:43Z INF Version 2022.2.1 2022-02-19T13:25:43Z INF GOOS: linux, GOVersion: go1.17.5, GoArch: amd64 2022-02-19T13:25:43Z INF Settings: map[protocol:quic url:localhost] 2022-02-19T13:25:43Z INF cloudflared will not automatically update if installed by a package manager. 2022-02-19T13:25:43Z INF Generated Connector ID: d05eef27-8e24-42e8-9ebd-5fa9bd15ee77 2022-02-19T13:25:43Z INF Initial protocol quic 2022-02-19T13:25:43Z INF Starting metrics server on 127.0.0.1:34563/metrics 2022/02/19 18:55:44 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details. 2022-02-19T13:25:47Z INF Connection 08c3c41a-5cce-47f2-8092-b6c316656b27 registered connIndex=0 location=DEL 2022-02-19T13:25:48Z INF Connection d5adf8c0-9c6d-4a4f-9d52-5b5cffb56158 registered connIndex=1 location=BOM 2022-02-19T13:25:49Z INF Connection c9fd3125-a27c-4cb5-aa9f-a026e0daf153 registered connIndex=2 location=DEL 2022-02-19T13:25:50Z INF Connection e6a1a777-fd7a-4fa1-b3ca-c335ea3bb6df registered connIndex=3 location=BOM
Here the tunnel of cloud flare will start and here you will get
the external link from where you can access the webpage through that
link.
https://justify-caribbean-surveillance-align.trycloudflare.com
So as you can you can use this URL to anywhere to open your webpage.
Binary Format
Now we will use cloud flare tunnel through binary format and lets see how to run localhost webpage in cloud tunnel without any installation .
Download Here - Click Here
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
After downloading this binary file we will give it executable permission with this command.
chmod +x filename
chmod +x cloudflared-linux-amd64
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 [sudo] password for hackerboy: --2022-02-19 21:18:25-- https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 Resolving github.com (github.com)... 13.234.176.102 Connecting to github.com (github.com)|13.234.176.102|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://github.com/cloudflare/cloudflared/releases/download/2022.2.1/cloudflared-linux-amd64 [following] --2022-02-19 21:18:31-- https://github.com/cloudflare/cloudflared/releases/download/2022.2.1/cloudflared-linux-amd64 Reusing existing connection to github.com:443. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/106867604/819d2f5b-4735-4016-8e7f-dd5a1da0e0be?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220219T154831Z&X-Amz-Expires=300&X-Amz-Signature=1fa7b4ee7b825c64bef6fcbc067c8a7dce218ea5a940dec1567267cb796d1edc&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=106867604&response-content-disposition=attachment%3B%20filename%3Dcloudflared-linux-amd64&response-content-type=application%2Foctet-stream [following] --2022-02-19 21:18:32-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/106867604/819d2f5b-4735-4016-8e7f-dd5a1da0e0be?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220219T154831Z&X-Amz-Expires=300&X-Amz-Signature=1fa7b4ee7b825c64bef6fcbc067c8a7dce218ea5a940dec1567267cb796d1edc&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=106867604&response-content-disposition=attachment%3B%20filename%3Dcloudflared-linux-amd64&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.110.133, 185.199.109.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 31683450 (30M) [application/octet-stream] Saving to: ‘cloudflared-linux-amd64’ cloudflared-linux-amd64 100%[====================================================================================================>] 30.21M 4.37MB/s in 12s 2022-02-19 21:18:45 (2.61 MB/s) - ‘cloudflared-linux-amd64’ saved [31683450/31683450] ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo chmod +x cloudflared-linux-amd64 [sudo] password for hackerboy: ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ ls -la cloudflared-linux-amd64 -rwxr-xr-x 1 root 1006 31683450 Feb 18 16:39 cloudflared-linux-amd64 ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$
Then we will run this binary file with our localhost webpage-
sudo ./cloudflared-linux-amd64 --url localhost
┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/CloudTunnel-hackingtruth.org] └─$ sudo ./cloudflared-linux-amd64 --url localhost 2022-02-19T16:26:42Z INF Thank you for trying Cloudflare Tunnel. Doing so, without a Cloudflare account, is a quick way to experiment and try it out. However, be aware that these account-less Tunnels have no uptime guarantee. If you intend to use Tunnels in production you should use a pre-created named tunnel by following: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps 2022-02-19T16:26:42Z INF Requesting new quick Tunnel on trycloudflare.com... 2022-02-19T16:26:47Z INF +--------------------------------------------------------------------------------------------+ 2022-02-19T16:26:47Z INF | Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): | 2022-02-19T16:26:47Z INF | https://douglas-rating-ipod-sperm.trycloudflare.com | 2022-02-19T16:26:47Z INF +--------------------------------------------------------------------------------------------+ 2022-02-19T16:26:47Z INF Version 2022.2.1 2022-02-19T16:26:47Z INF GOOS: linux, GOVersion: go1.17.5, GoArch: amd64 2022-02-19T16:26:47Z INF Settings: map[protocol:quic url:localhost] 2022-02-19T16:26:47Z INF Generated Connector ID: add6d356-538d-44bd-96ed-cfae16fbbb46 2022-02-19T16:26:47Z INF cloudflared will not automatically update if installed by a package manager. 2022-02-19T16:26:47Z INF Initial protocol quic 2022-02-19T16:26:47Z INF Starting metrics server on 127.0.0.1:38095/metrics 2022/02/19 21:56:47 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details. 2022-02-19T16:26:49Z INF Connection de96c7e8-6c8a-4640-9bcd-c974b5ea2a9f registered connIndex=0 location=DEL 2022-02-19T16:26:51Z INF Connection fdddac53-0697-43d7-82e1-a1eccfe55183 registered connIndex=1 location=BOM 2022-02-19T16:26:52Z INF Connection edd58d91-8470-4f7d-b9db-cad503266726 registered connIndex=2 location=DEL 2022-02-19T16:26:52Z INF Connection e23aac84-a055-49a2-9d16-550e4f1f50b0 registered connIndex=3 location=BOM
https://douglas-rating-ipod-sperm.trycloudflare.com/
I hope you liked this post, then you should not forget to share this post at
all.
Thank you so much :-)