VirtualHost is not taken as the best match

by Lahiru Jayathilake   Last Updated March 13, 2018 07:00 AM

I have a file called pga-default.conf which looks like,

<VirtualHost *:8008>
    ServerName 192.168.1.10

    DocumentRoot /var/www/portals/default/public

    <Directory "/var/www/portals/default/public">
       AllowOverride All
    </Directory>
    ErrorLog /var/log/httpd/default.error.log
    CustomLog /var/log/httpd/default.requests.log combined
</VirtualHost>

Problem is whenever I try with http://192.168.1.10:8008 it always loads the default Apache Testing page. default.conf looks like,

Listen 8008
<VirtualHost _default_:8008>
    DocumentRoot "/www/default"
</VirtualHost>

But when I change the <VirtualHost *:8008> into <VirtualHost 192.168.1.10:8008> in pga-default.conf it works as expected. I want to know why is this. As far as I know, this is because the server doesn't pick the VirtualHost as the best match for the particular IP address and port. (This answer confirms that difference between _default_:* and *:* in VirtualHost Context)

I tried several other methods as well, but none of them worked except the above-mentioned method. Following are the other methods. (Changes for pga-default.conf)

  • Change ServerName 192.168.1.10 to ServerName 192.168.1.10:8008
  • Used ServerAlias 192.168.1.10

Note - With the above configuration <VirtualHost *:8008> some of my colleagues have received successful results. This problem occurred only for me.

What have I missed here? How come others getting the expected results while I am not?



Related Questions


centos 6.9 Virtual host configuration not working

Updated August 23, 2017 09:00 AM

Apache 2.4 on Centos 7 in Home - Permission Denied

Updated September 21, 2017 20:00 PM



Apache HTTP to HTTPS Redirection on none HOST NAME

Updated March 29, 2015 15:00 PM