0

I have around 130 IPs on my linux server. 125 IPs point to one site, and 5 of them point to another. I would like to make just two virtualhost definitions.

Currently I am doing a wildcard at the top, and then separate Vhosts for each of the 5 IPs..The problem that I run into is sometimes it will trigger to pickup the wildcard (*) vhost when it can't find anything on the other 5.

3 Answers 3

1

I don't think there will be any pretty or elegant way to do this with all those IP's but it looks like this may be your best bet: http://httpd.apache.org/docs/2.0/vhosts/examples.html#intraextra

It looks like you can space separate IP in the VirtualHost declaration

<VirtualHost 192.168.1.1:80 172.20.30.40:80 3.other.IPs>
    DocumentRoot /www/example1
    ServerName www.example1.org
</VirtualHost>

Then just use the default setup to take in the other 125 ips

<VirtualHost _default_:80>
    DocumentRoot /www/example2
    ServerName www.example2.org
</VirtualHost>

Hope this helps!

1

You should be able to define a default virtual host for the 125 IP pointing to the one site as follows

<VirtualHost _default_:80>
...
</VirtualHost>

and then one virtual host for every one of the 5 'special' IPs.

3
  • I do that now...
    – user36644
    Mar 3, 2010 at 19:18
  • Are you doing a wildcard (VirtualHost *) or the default one I suggested ?
    – Dominik
    Mar 3, 2010 at 19:26
  • I do a * but I need to do two of them so I cant use it twice.
    – user36644
    Mar 3, 2010 at 22:35
0

You could write scripts to generate per-ip vhost.

1
  • There is no exceptions that can be made? Or any kind of range
    – user36644
    Mar 3, 2010 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .