I have Apache configure with several IP addresses:
Listen 111.111.111.111:80
Listen 111.111.111.111:443
Listen 222.222.222.222:80
Listen 222.222.222.222:443
Listen 333.333.333.333:80
Listen 333.333.333.333:443
(IPs are fake)
I have several VirtualHosts, one of which is a wildcard subdomain.
<VirtualHost *:80>
ServerName *.example1.com
DocumentRoot /var/www/vhosts/example1-wc/docs
</VirtualHost>
<VirtualHost *:80>
ServerName www.example1.com
DocumentRoot /var/www/vhosts/example1/docs
</VirtualHost>
<VirtualHost *:80>
ServerName www.example2.com
DocumentRoot /var/www/vhosts/example2/docs
</VirtualHost>
This works fine. Requests to www.example1.com are served under the example1 docroot, requests for example.example1.com are served under the example1-wc docroot and www.example2.com for example2 docroot.
I can change www.example2.com to use a specific IP without any problems however if I change the wildcard vhost *.example1.com to a specific IP:
<VirtualHost 111.111.111.111:80>
ServerName *.example1.com
DocumentRoot /var/www/vhosts/example1-wc/docs
</VirtualHost>
Then requests to www.example1.com create an infinite redirect loop on itself. This happens regardless of whether I use:
<VirtualHost 222.222.222.222:80>
ServerName www.example1.com
DocumentRoot /var/www/vhosts/example1/docs
</VirtualHost>
or
<VirtualHost *:80>
ServerName www.example1.com
DocumentRoot /var/www/vhosts/example1/docs
</VirtualHost>
Why is this happening and how can I get each virtualhost on its own IP?
I'm not sure if this is the root of your problem, but you should probably have the directives
So the full configuration would have these directives in it:
but this should not appear anywhere:
Here's some further reading, if you're interested: http://httpd.apache.org/docs/2.2/vhosts/details.html (good luck making sense of it ;-)
Just a wild guess, but have you tried putting the definition for the wildcard subdomain after the www.example1.com definition?