1
votes

I have a Varnish setup for one of my sites. I'm using the open source software Piwik for my stats tracking.

Piwik have an option of having a Proxy for tracking, which means that the URL of Piwik won't be revealed in my source code. Basically it's a PHP file that sits on my wordpress install and it sends CURL posts to my Piwik install...

Now, I set up my Varnish using: https://github.com/mattiasgeniar/varnish-3.0-configuration-templates

In vcl_fetch I added:

if (req.url ~ "piwik") {
    set beresp.ttl = 120s;
    return (hit_for_pass);
}

In vcl_recv I added:

if (req.url ~ "piwik") {
    return (pass);
}

What happens is, I see only 50% of the traffic I actually have on the website...

I'm afraid it's because of my vcl_fetch settings...

I read the differences between pass and hit_for_pass and from what I understand beresp.ttl is a config that I guides varnish to keep doing pass for 120s

One more thing, W3TotalCache on WP adds some caching headers like Max-Age & expires to my piwik.php file. Without Varnish it's still working well and tracking correctly. Is it possible that there is some sort of collision between Varnish and those headers?

Do I get it right? Why do you think 50% of my tracking is missed?

Thanks.

1
1. What's the PATH string of the PHP script? 2. Is the real "hidden" Piwik tracker also behind Varnish? If so, what is its PATH?Ludwik Trammer
Hey, The Real PIWIK is not under Varnish. The path is /wp-content/wp-piwik/piwik.php Thanks.tounano
Unfortunately I don't know what's wrong then. vcl_fetch code is completely redundant in you case, and the url regex should be more specific, but still - as far as I know what you have should work.Ludwik Trammer

1 Answers

0
votes

The Varnish configuration for pass-ing in vcl_recv is correct.

The code you have in vcl_fetch can be removed, it doesn't make any difference at that point because of the code in recv.

Remember that any VCL code that filters response headers in vcl_fetch is also run for pass-ed responses. I'd guess that you are filtering the Set-Cookie that piwik sends.