Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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!

share|improve this answer

You could write scripts to generate per-ip vhost.

share|improve this answer
    
There is no exceptions that can be made? Or any kind of range –  user36644 Mar 3 '10 at 19:18

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.

share|improve this answer
    
I do that now... –  user36644 Mar 3 '10 at 19:18
    
Are you doing a wildcard (VirtualHost *) or the default one I suggested ? –  Dominik Mar 3 '10 at 19:26
    
I do a * but I need to do two of them so I cant use it twice. –  user36644 Mar 3 '10 at 22:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.