skip to Main Content

My Azure VM is up running, passed diagnostics. I can ssh into it, but ping public-ip failed.

Some details:

UbuntuVM:~$ curl localhost:80

Welcome to nginx!

But if I curled the index.html from my PC, it failed:

root@DESKTOP-7H7HR2B:/mnt/c/# curl http://52.148.136.139/index.html

curl: (7) Failed to connect to 52.148.136.139 port 80 after 21052 ms: Couldn’t connect to server

I put the public IP 52.148.136.139 in the web browser url and got The connection timed out.

Both /var/log/nginx/error.log and access.log are empty.

The setup seems to be good:

$ systemctl status nginx shows the web server is active(running)

$ vi /etc/nginx/sites-available/default and it has listen 80 default_server;

$ ls -al /var/www/html

drwxr-xr-x 2 755 www-data 4096 Dec 19 04:12 .

-rwxr-xr-x 1 root root 612 Dec 19 04:12 index.html (content page)

I’ve also configured the networking security group inbound and outbound as below.
enter image description here

What could be wrong?

2

Answers


  1. Chosen as BEST ANSWER

    @venkat I followed your steps with ufw disable as well as allow 80/tcp and it still failed. I tried telnet 52.148.136.139 80 and 8080, both failed. I then noticed the NSG rule Name has a yellow triangle. Once I added a rule with the Src Port ranges changed to Any *, there are no more yellow signs and the index.html is successfully displayed.Inbound src port set to allow Any port Index.html displayed on the Chrome browser

    telnet 52.148.136.139 80 also works.


  2. Unable to browse the Azure Ubuntu VM using its public IP in url

    The error you encountered is due to firewall rules or Nginx configurations. Follow the steps below to resolve the issue.

    Verify the VM’s firewall status using the cmdlet: sudo ufw status. If the firewall is disabled, there is no need to open port 80. If it is enabled, ensure that HTTP traffic is allowed.

    enter image description here

    sudo ufw allow 80/tcp
    

    Check that Nginx is running and correctly configured to listen on port 80 by navigating to /etc/nginx/sites-available/default file.

    sudo nano /etc/nginx/sites-available/default
    

    Make sure that theserver block contains the correct rootandā£index directives.

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
    
        root /var/www/html;
        index index.html;
    
        server_name _;
    
        location / {
            try_files $uri $uri/ =404;
        }
    }
    

    You can run the following command to verify that the index.html file exists in the directory.

    ls -l /var/www/html/index.html
    

    Test Nginx Configuration

    sudo nginx -t
    

    Reload Nginx to apply the changes.

    sudo systemctl reload nginx
    

    enter image description here

    Ensure that Nginx has the correct permissions to access the index.html file

    sudo chown www-data:www-data /var/www/html/index.html
    sudo chmod 644 /var/www/html/index.html
    

    NSG Rule:

    enter image description here

    If all the configurations are correct, try to access the site, and it should display the index.html content.

    http://172.191.87.244/index.html
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search