Search code examples
web-hostingwindows-server-2012apache2.4

Hosting multiple site on apache server in windows 2012 server


I am trying to host two sites on apache 2.4 server which is running in windows 2012 server. I have added vhost entries for two sites one running on 80 and other on 8080.

Sample vhost entries:

<VirtualHost *:80>
  DocumentRoot "/www/example1"
  ServerName www.example.com
</VirtualHost>

<VirtualHost *:8080>
  DocumentRoot "/www/example2"
  ServerName www.example2.com
</VirtualHost>

With this configuration both the domain points to site running on port 8080. Considering above sample, sites opens same code in directory /www/example1 on both www.example.com and www.example2.com domains.

But if I access site with I.P. like http://198.21.22.1:80 and http://198.21.22.1:8080 the sites work fine but through domains it does not.

We have a load balancer in between which point to the actual server.

Need to know what configurations or setting if any I have missed.

I have added Listen entries for 80 and 8080 in httpd.conf file.

UPDATE

On further analysis I found that, from different systems different version of site opens up. Example, from my system both the domain opens up code running from /www/example1, but from my mobile client it opens up code running from /www/example2 for both domains.

So, I checked from some other system and found that it opens code running from /www/example1 for both domains and again from some other system it opens up code running from /www/example2 for both domains.

We have a load balancer in between which redirects to the http server on which /www/example1 and /www/example2 are present. Currently I do not have access to this load balancer, but can load balancer be cause of this issue?

Thanks, Uday


Solution

  • I just added virtualhost entries with same port 80 for both sites with different servername.

    Issue was with tow systems being present had to make changes on both server in the load balance cluster.