httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: [users@httpd] Virtual Host Performance Oddity
Date Wed, 31 Dec 2008 11:49:25 GMT
J. Greenlees wrote:
[...]
As slightly off-topic, I would like to add a note :

Because of the way in which VirtualHosts work, with the first-defined 
VHost being the one handling all requests which somehow are "wrong", it 
is often difficult to sort out where such problems are coming from.
To avoid this, I usually define a first Vhost that has some non-real DNS 
ServerName  (e.g. ServerName defaulthost), specifically to catch 
requests that arrive at the server with an invalid hostname (for example 
someone entering "http://(server-ip-address)".  That one has a 
DocumentRoot containing a single html index page, which shows clearly 
that the caller shouldn't do that. It also has its own separate logfiles.
That helps sorting out the "wrong" calls from the "good" calls.

In your case, that would be something like :

<VirtualHost *:80>
     ServerName default
     DocumentRoot /home/defaulthost/docs
     DirectoryIndex DontDoThat.html
     ErrorLog /var/log/httpd/defaulthost-error_log
     CustomLog /var/log/httpd/defaulthost-access_log common
</VirtualHost>

<VirtualHost *:80>
     ServerAdmin
     DocumentRoot /home/jaqui/public_html
     ServerName dev.runic-hosting.com
     ErrorLog /var/log/httpd/dev.runic-hosting.com-error_log
     CustomLog /var/log/httpd/dev.runic-hosting.com-access_log common
</VirtualHost>

<VirtualHost *:80>
     ServerAdmin
     DocumentRoot /home/dawnfyre/public_html
     ServerName dev.jaqui-greenlees.net
     ErrorLog /var/log/httpd/dev.jaqui-greenlees.net-error_log
     CustomLog /var/log/httpd/dev.jaqui-greenlees.net-access_log common
</VirtualHost>

<VirtualHost *:80>
     ServerAdmin
     DocumentRoot /home/shawan/public_html
     ServerName dev.shawanspage.com
     ErrorLog /var/log/httpd/dev.shawanspage.com-error_log
     CustomLog /var/log/httpd/dev.shawanspage.com-access_log common
</VirtualHost>

Since "default" is not a valid DNS name, nobody would ever get to your 
server using "http://default".  But that host would catch calls to 
"http://ip-address-of-your-server", and also re-directed calls that 
somehow do not have a "Host:" header, or an invalid one (like possibly 
the result of wrong re-directs).
And in its logfile, you would have these calls isolated from the 
explicit calls to your host "dev.runic-hosting.com".


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message