Remote Tunnel to a Web Server
Remote Tunnel to a Web Server
This document describes how to use Microsoft Dev tunnels to connect to a web server running on a remote machine.
Imagine this scenario: you are working on a web application that is running on your local machine, and you want to show it to a friend or a colleague. You can use this feature to share your local web server with them.
In order to do that, you first need to have a Microsoft or a GitHub account. In this document, I am using a Microsoft account.
Let's get started!
Step 1 - Install devtunnel CLI
Run the following command to install the devtunnel
CLI:
curl -sL https://aka.ms/DevTunnelCliInstall | bash
See Install the DevTunnel CLI for more information.
Step 2 - Start a web server on your local machine
In this example, I am using a simple web server that serves a static HTML page. You can use any web server you want.
# Create a simple HTML page that says "Hello World"
echo "Hello World" > index.html
# Start a simple web server that serves the index.html file
python3 -m http.server 8080
Step 3 - Create a devtunnel to the web server
Login to your Microsoft account using device code authentication:
devtunnel user login -d
Create a temporary devtunnel to the web server on port 8080, and allow anonymous access:
devtunnel host -p 8080 --allow-anonymous
Step 4 - Access the web server from the browser
- Open your browser and navigate to the URL that was printed in the previous step.
- You should see the "Hello World" page.