Search code examples
azure-virtual-machineazure-nsg

How to access Azure ubantu http 80 port?


I use "flask run -p 80" to start a python web api in Azure ubantu 22.

  1. I use curl to test it successfully in VM

  2. I open firewall for 80 enter image description here

  3. I also add security rule for azure NSG, it test successfully. enter image description here

But I can not access the flask 80 portal use my local browser. Please help to advice what i need to do next? Thanks so much!


Solution

  • How to access Azure ubuntu http 80 port? I have followed the methods below to run the application on port 80 in the Ubuntu VM

    Note: For testing I deployed NGINX

    Check if your application is listening on the correct port 8080 for the foreign Address 0.0.0.0:* by using below command. If not, you could find what's IP of the application consumed.

     #Install nettools
    sudo apt install net-tools
    sudo netstat -alpn | grep LISTEN
    

    Output:

    enter image description here

    When I try with 8080, it's not working, but it's working with 80 as below.

    enter image description here

    NSG Rules

    Make sure to add the same port in the NSG as the port that is listening on the VM

    enter image description here

    When I try to access the application hosted on the Ubuntu VM using the public IP with port 80, it starts working as below.

    20.56.41.235:80
    

    enter image description here

    If still not working disable the local firewall on Ubuntu VM by using the command below.

    sudo ufw disable