Accessing a webserver running on Linux VM in a lab

Copper Contributor

Hi all,

 

I am exploring the Azure Lab service. I have a Linux VM in which I want to run a Web server. The web page needs to be accessed from outside of Azure. Is it possible to do that and if yes then what settings need to be done for that.

 

Thanks,

Joydeep

1 Reply

@Joydeep2021 It's not possible to directly open a port on your lab VM to be able to access the web service (only SSH\RDP ports can be enabled).  Can you provide more details on your scenario, such as the type of web service\application that you are trying to access outside the VM?

 

To work around this, you can try creating an ssh tunnel between your local machine and your lab VM and use port forwarding.  Here's the basic steps that you can try:

  1. Ensure the VM is started.

  2. Copy the SSH connection string for your lab VM. Your connection string will look similar to this:

    ssh -p 12345 testuser@ml-lab-00000000-0000-0000-0000-000000000000.centralus.cloudapp.azure.com
  3. On your local computer, open a terminal or command prompt. Paste the SSH connection string and add -L 8000:localhost:8000 (except, put in your port number in place of 8000) into the command string, which creates a “tunnel” between your local computer and the lab VM. The final command string should look like this:

    ssh -p 12345 -L 8000:localhost:8000 testuser@ml-lab-00000000-0000-0000-0000-000000000000.centralus.cloudapp.azure.com

    Hit Enter to run the command. When prompted, provide your password to the template VM. At this point, the tunnel should now be established. Leave this command window open.

IMPORTANT: If you receive the following message, specify yes to continue: The authenticity of host '[ml-lab-00000000-0000-0000-0000-000000000000.central.cloudapp.azure.com]:12345 ([52.191.16.234]:12345)' can't be established. ECDSA key fingerprint is SHA256:46MUVWAZ+gKvzUuReiIpfZrrlXACqL+6hrelT8UNT9U. Are you sure you want to continue connecting (yes/no)?" then the password.

 

With the SSH tunnel established, you now should be able to open your browser on your local machine and access the web service by providing the url - continuing with the above example, you would put in a url such as https://localhost:8000.