varnishncsa and virtual hosts
Raymond Hall
kova70 at gmail.com
Sat Aug 9 03:59:12 CEST 2008
A pretty simple hack to varnishncsa did the trick nicely:
diff -ru varnish-2.0.tp2/bin/varnishncsa/varnishncsa.c
varnish-2.0.tp2.hack/bin/varnishncsa/varnishncsa.c
--- varnish-2.0.tp2/bin/varnishncsa/varnishncsa.c 2008-07-05
16:41:36.000000000 -0500
+++ varnish-2.0.tp2.hack/bin/varnishncsa/varnishncsa.c 2008-07-22
07:07:03.000000000 -0500
@@ -424,6 +424,15 @@
strftime(tbuf, sizeof tbuf, "[%d/%b/%Y:%T %z]", &lp->df_t);
fprintf(fo, "%s ", tbuf);
+ if (lp->df_Host) {
+ if (strncmp(lp->df_Host, "http://", 7) == 0) {
+ fprintf(fo, lp->df_Host + 7);
+ } else {
+ fprintf(fo, lp->df_Host);
+ }
+ fprintf(fo, " ");
+ }
+
/*
* Fake "%r". This would be a lot easier if Varnish
* normalized the request URL.
This makes varnishncsa to log the host header separately, just after
the date sting. That way you can tell AWstats to use that field for
%virtualname
It's ugly but less uglier than the other workarounds I've seen :)
Regards,
Raymond Hall
On Fri, Jul 25, 2008 at 8:18 AM, Anders Nordby <anders at fupp.net> wrote:
> Hi,
>
> I'm using an ugly cron-based work-aroud. ;-) Seems to work ok. But yes,
> I'd appreciate very much if we could write separate logs for different
> virtual hosts. Preferably, even without running one instance of
> varnishncsa for every log.
>
> On Fri, Jul 25, 2008 at 04:44:28AM -0500, Raymond Hall wrote:
>> I've run through pretty much all posts regarding separating
>> varnishncsa's output per hosts, as requested in RxHeader.
>> So far, no one has posted a reliable solution ... if only varnishlog
>> accepted both -o and -w ... or varnishncsa RxHeader worked... :)
>> No use redirecting varnishlog -o -c RxHeader '^Host: www.example.com'
>> to a fifo and ther asking varnishncsa to read from it.
>>
>> Has anyone found a reliable solution to this? (ie. other than
>> resorting to ugly cron-based workarounds....)
>> I'm using varnish-2.0-tp2
>>
>> TIA,
>> Ray
>>
>> --
>> I'd rather have an inch of a dog than miles of pedigree.
>>
>> Dana Burnet
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc at projects.linpro.no
>> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
>
> --
> Anders.
>
--
I'd rather have an inch of a dog than miles of pedigree.
Dana Burnet
More information about the varnish-misc
mailing list