0

I am setting up Active Collab Site in my new server. The setup is like below

Internet> ---> varnish ----> apache

But i am not able to login to the site through varnish cache.. But i can login to site through apache.

Here is my VCL file

backend default { .host = "localhost"; .port = "8080"; }
acl purge { "localhost"; }
sub vcl_recv { if (req.request == "PURGE") { if (!client.ip ~ purge) { error 405 "Not allowed."; } return(lookup); }
if (req.url ~ "^/$") { unset req.http.cookie; } }
sub vcl_hit { if (req.request == "PURGE") { set obj.ttl = 0s; error 200 "Purged."; } }
sub vcl_miss { if (req.request == "PURGE") { error 404 "Not in cache."; }
if (!(req.url ~ "wp-(login|admin)")) { unset req.http.cookie; }
if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") {
unset req.http.cookie;
set req.url = regsub(req.url, "\?.$", "");
}
if (req.url ~ "^/$") { unset req.http.cookie; } }
sub vcl_fetch { if (req.url ~ "^/$") { unset beresp.http.set-cookie; }
if (!(req.url ~ "wp-(login|admin)")) { unset beresp.http.set-cookie; }}

When i try to login through varnish i was redirect back to login page. If i enter wrong password, then it will ask for enter correct password.

3
  • It seems to me that it is probably cookie related. Only unset the cookies if it's really a resource. The (!(req.url ~ "wp-(login|admin)")) parts might not work as expected.
    – AndreasM
    Jan 11, 2012 at 8:30
  • As i am new to varnish i don't understand what you are talking. The VCL is the default one with the installation. I didn't changed it.
    – ArunS
    Jan 11, 2012 at 8:52
  • If it's a supplied vcl file, then it's probably a version mix-up. Maybe you are using a newer Active Collab version and the vcl isn't compatible anymore.
    – AndreasM
    Jan 13, 2012 at 13:59

1 Answer 1

1

At last i found the solution.

I have added the following code under "sub vcl_fetch" section.

if (beresp.http.set-cookie ~ "sessionid" || beresp.http.set-cookie ~ "csrftoken") {
       return (pass);
    } else {
       return (deliver);
    }

Now I can able to login through varnish!!!

I found this solution from this site.

Thanks,

Arun S

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .