Answer 1 is correct and I would add with the name virtualhosts as the first entry essentially matches any virtualhost that is not named elsewhere
it should ONLY be used to catch unintentional malformed and broken traffic
those. machene with one ip is called john.domain.com, running on www.domain.com and www.domain2.com, since the actual web servers on ip www.xxx.yyy.zzz can have an optimal configuration, for example,
<VirtualHost *:80> DocumentRoot /var/webserver/static-sites/unknown/ # a directory readable by apache with only a robots.txt denying everything ServerName bogus ErrorDocument 404 "/errordocuments/unknown-name.html" #custom 404 describing how/what they might have done wrong try pointing a browser {with a hosts file at http://bogus/ on 193.120.238.109 to see mine# ErrorLog /var/log/httpd/unknown-error.log CustomLog /var/log/httpd/unknown-access.log combined </VirtualHost> <VirtualHost *:80> DocumentRoot /var/webserver/static-sites/unknown/ # a possibly different directory readable by apache with only a robots.txt denying everything ServerName www.xxx.yyy.zzz ServerAlias john.domain.com ErrorDocument 404 "/errordocuments/ip-name.html" ErrorDocument 403 "/errordocuments/ip-name.html" #custom 404 telling them as a likely hacker/bot you wish to have nothing to do with them see mine at http://193.120.238.109/ ErrorLog /var/log/httpd/ip-error.log CustomLog /var/log/httpd/ip-access.log combined </VirtualHost> <VirtualHost *:80> ServerName domain.com RedirectPermanent / http://www.domain.com/ ErrorLog logs/www.domain.com-error.log CustomLog logs/www.domain.com-access.log combined </VirtualHost> <VirtualHost *:80> DocumentRoot /var/webserver/ftpusers/domain ServerName www.domain.com ServerPath /domain ErrorLog logs/www.domain.com-error.log CustomLog logs/www.domain.com-access.log combined </VirtualHost> <VirtualHost *:80> ServerName domain2.com RedirectPermanent / http://www.domain2.com/ ErrorLog logs/www.domain2.com-error.log CustomLog logs/www.domain2.com-access.log combined </VirtualHost> <VirtualHost *:80> DocumentRoot /var/webserver/ftpusers/domain2 ServerName www.domain2.com ServerPath /domain2 ErrorLog logs/www.domain2.com-error.log CustomLog logs/www.domain2.com-access.log combined </VirtualHost>
Alan doherty
source share