View Single Post
  #7   (View Single Post)  
Old 21st November 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

Separate the virtual hosts sections from the main httpd.conf. Put all of them in a single file. Use the "Include" directive to include this virtualhost-only configuration file into the main httpd.conf.

There are two possibilities:
  1. The virtual hosts configurations are identical

    In this case you could just regenerate them using my first script.
    In that script I used a simplified <VirtualHost> section. You will have to adapt the first script to generate an exact clone of your <VirtualHost> directives.
  2. The virtual host entries are not identical

    In this case, updating the IP address is the best solution.
    This has the disadvantage that the script will be more complex. You will need to ask somebody proficient in and scripting language like Perl, Python or Ruby to write it for you.

BTW a possible simpler way would be to scan for the virtual host names and use dig to resolve the name to the IP address[/b].
A couple of ServerName entries to test:
Code:
$ grep ServerName virtual-sample  
    ServerName accounttest.com
    ServerName gorilla.org
    ServerName monkey.org
A simple shell script
Code:
#!/bin/sh
FILE=virtual-sample

ALL=$( sed -ne 's/^[[:blank:]]*ServerName  *//p' ${FILE} )

for Host in ${ALL} ; do
   echo "${Host}=$(dig +short -t A ${Host})"
done
A sample run
Code:
$ sh dig-them        
accounttest.com=
gorilla.org=128.121.215.221
monkey.org=152.160.49.201
By redirecting the output to file you have a list of all the virtual hosts and their IP addresses, which can be used in either approach 1 or 2 as outlined above.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote