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.
What could be wrong?
2
Answers
@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.
telnet 52.148.136.139 80 also works.
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.
Check that Nginx is running and correctly configured to listen on port 80 by navigating to
/etc/nginx/sites-available/default
file.Make sure that the
server
block contains the correctroot
andā£index
directives.You can run the following command to verify that the
index.html
file exists in the directory.Test Nginx Configuration
Reload Nginx to apply the changes.
Ensure that Nginx has the correct permissions to access the
index.html
fileNSG Rule:
If all the configurations are correct, try to access the site, and it should display the
index.html
content.