Skip to content
Advertisement

Unable to access apache page on Linux Azure VM

I’ve setup a linux VM in Azure. I’ve added incoming port access to the current listening port on Apache. I’ve also done a curl localhost on the VM and see the apache html text. I hit the public IP of the VM and get nothing. Any ideas?

Advertisement

Answer

According to your description, please check those settings:
1. Please check Azure VM’s NSG settings, make sure we have add port to inbound rules:enter image description here 2. Vnet–>subnet’s security group settings: enter image description here 3. Check which port apache listening on: netstat -ant

root@ubuntu:~# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 10.1.0.4:55870          191.237.32.134:443      TIME_WAIT  
tcp        0      0 10.1.0.4:55874          191.237.32.134:443      TIME_WAIT  
tcp        0      0 10.1.0.4:55876          191.237.32.134:443      TIME_WAIT  
tcp        0      0 10.1.0.4:55868          191.237.32.134:443      TIME_WAIT  
tcp        0      0 10.1.0.4:57772          168.63.129.16:80        TIME_WAIT  
tcp        0      0 10.1.0.4:57766          168.63.129.16:80        TIME_WAIT  
tcp        0     36 10.1.0.4:22             167.220.255.8:53651     ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN  

By the way, for test please disable ufw with this command ufw disable, then try to access the public IP address.

Update:
I follow those steps to modify apache default port:
1.Modify ports.conf, change port 80 to 80:

root@ubuntu:/etc/apache2# vi ports.conf
Listen 90

<IfModule ssl_module>
        Listen 443

2.Add ServerName localhost to /etc/apache2/apache2.conf

root@ubuntu:/etc/apache2# vi /etc/apache2/apache2.conf
# Global configuration
#
ServerName localhost

3.Modify default port in /etc/apache2/sites-enabled/000-default.conf

root@ubuntu:/etc/apache2# vi /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:90>

4.Add inbound rule to Network Security Group: enter image description here

By the way, to troubleshoot this issue, we can follow those steps:
1.Login this VM and use curl to test apache2:

curl localhost:90

2.Use your PC to telnet this VM’s public IP and port 90

telnet xx.xx.xx.xx 90

If you can’t telnet this port, please check your NSG settings and subnet’s security group settings.

Here is my result, it works for me:

root@ubuntu:/etc/apache2# netstat -ant | grep 90
tcp6       0      0 :::90                   :::*                    LISTEN    
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement