Web Hosting Talk







View Full Version : mod_log_config


freakysid
10-05-2001, 07:01 PM
I've been looking over the documentation:
http://httpd.apache.org/docs/mod/mod_log_config.html

What I want to do is to log the HTTP_HOST value in the log file. This is because I am web serving under several domain names (name based hosting) - but I am not using virtual servers. Yet I still want to know which requests have come in under which domain name.

Am I right in thinking that if I set:

UseCanonicalName off

and then specify %V in the log format directive, that this will give me what I am after (the host according to the client's request)?

I will play with this myself - but if someone already knows the answer... :)

Jm4n
10-06-2001, 08:00 AM
Quoting from the documentation:
%...{Foobar}i: The contents of Foobar: header line(s) in the request
I think this might be better, as it doesn't rely on the UseCanonicalName setting and thus you can set that as you wish without affecting your logging.

I believe if a user accesses a site via IP (which would show whatever site is the 'default' site), the browser sends the IP as the HTTP_HOST -- but if someone visits using an HTTP 1.0 agent (eg, a very, very old browser), this field would be blank.

Just something to consider if your stats processing tools may rely on this field.

PS -- the header you would want would simply be "Host", eg:

%{Host}i

Also keep in mind that this can easily be forged or otherwise set to an invalid domain, since it's sent by the browser. However, if you're just using this for statistical purposes, it should be fine.

freakysid
10-06-2001, 06:58 PM
Of course, the old FOOBAR header ;)

Thanks for pointing that out. I hadn't quite groked the documentation - didn't read it carefully enough. That is great.

Yes - its just for statistical & logging purposes. I'm going to write my own script to analyse the logs.