Accessing a webserver running on Linux VM in a lab

%3CLINGO-SUB%20id%3D%22lingo-sub-1870449%22%20slang%3D%22en-US%22%3EAccessing%20a%20webserver%20running%20on%20Linux%20VM%20in%20a%20lab%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1870449%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20exploring%20the%20Azure%20Lab%20service.%20I%20have%20a%20Linux%20VM%20in%20which%20I%20want%20to%20run%20a%20Web%20server.%20The%20web%20page%20needs%20to%20be%20accessed%20from%20outside%20of%20Azure.%20Is%20it%20possible%20to%20do%20that%20and%20if%20yes%20then%20what%20settings%20need%20to%20be%20done%20for%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EJoydeep%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1873876%22%20slang%3D%22en-US%22%3ERe%3A%20Accessing%20a%20webserver%20running%20on%20Linux%20VM%20in%20a%20lab%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1873876%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F790457%22%20target%3D%22_blank%22%3E%40Joydeep2021%3C%2FA%3E%26nbsp%3BIt's%20not%20possible%20to%20directly%20open%20a%20port%20on%20your%20lab%20VM%20to%20be%20able%20to%20access%20the%20web%20service%20(only%20SSH%5CRDP%20ports%20can%20be%20enabled).%26nbsp%3B%20Can%20you%20provide%20more%20details%20on%20your%20scenario%2C%20such%20as%20the%20type%20of%20web%20service%5Capplication%20that%20you%20are%20trying%20to%20access%20outside%20the%20VM%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20work%20around%20this%2C%20you%20can%20try%20creating%20an%20ssh%20tunnel%20between%20your%20local%20machine%20and%20your%20lab%20VM%20and%20use%20port%20forwarding.%26nbsp%3B%20Here's%20the%20basic%20steps%20that%20you%20can%20try%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CP%3EEnsure%20the%20VM%20is%20started.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3ECopy%20the%20SSH%20connection%20string%20for%20your%20lab%20VM.%20Your%20connection%20string%20will%20look%20similar%20to%20this%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%20highlight-source-shell%22%3E%0A%3CPRE%3Essh%20-p%2012345%20testuser%40ml-lab-00000000-0000-0000-0000-000000000000.centralus.cloudapp.azure.com%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EOn%20your%20local%20computer%2C%20open%20a%20terminal%20or%20command%20prompt.%20Paste%20the%20SSH%20connection%20string%20and%20add%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E-L%208000%3Alocalhost%3A8000%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3CSTRONG%3E(except%2C%20put%20in%20your%20port%20number%20in%20place%20of%208000)%26nbsp%3B%3C%2FSTRONG%3E%3C%2FSPAN%3Einto%20the%20command%20string%2C%20which%20creates%20a%20%E2%80%9Ctunnel%E2%80%9D%20between%20your%20local%20computer%20and%20the%20lab%20VM.%20The%20final%20command%20string%20should%20look%20like%20this%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%20highlight-source-shell%22%3E%0A%3CPRE%3Essh%20-p%2012345%20-L%208000%3Alocalhost%3A8000%20testuser%40ml-lab-00000000-0000-0000-0000-000000000000.centralus.cloudapp.azure.com%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3EHit%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EEnter%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20run%20the%20command.%20When%20prompted%2C%20provide%20your%20password%20to%20the%20template%20VM.%20At%20this%20point%2C%20the%20tunnel%20should%20now%20be%20established.%20Leave%20this%20command%20window%20open.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22%20padding-left%20%3A%2060px%3B%20%22%3E%3CSPAN%3EIMPORTANT%3A%20If%20you%20receive%20the%20following%20message%2C%20specify%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eyes%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bto%20continue%3A%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EThe%20authenticity%20of%20host%20'%5Bml-lab-00000000-0000-0000-0000-000000000000.central.cloudapp.azure.com%5D%3A12345%20(%5B52.191.16.234%5D%3A12345)'%20can't%20be%20established.%20ECDSA%20key%20fingerprint%20is%20SHA256%3A46MUVWAZ%2BgKvzUuReiIpfZrrlXACqL%2B6hrelT8UNT9U.%20Are%20you%20sure%20you%20want%20to%20continue%20connecting%20(yes%2Fno)%3F%22%20then%20the%20password.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22%20padding-left%20%3A%2060px%3B%20%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20SSH%20tunnel%20established%2C%20you%20now%20should%20be%20able%20to%20open%20your%20browser%20on%20your%20local%20machine%20and%20access%20the%20web%20service%20by%20providing%20the%20url%20-%20continuing%20with%20the%20above%20example%2C%20you%20would%20put%20in%20a%20url%20such%20as%20%3CA%20href%3D%22https%3A%2F%2Flocalhost%3A8000%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Flocalhost%3A8000%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

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.