0

I can't login from the front-end with varnish installed. Here's what I think it is issue

sub vcl_recv {

 # Do not cache these paths.
 if (req.url ~ "^/status\.php$" ||
  req.url ~ "^/admin$" ||
  req.url ~ "^/admin/.*$" ||
  req.url ~ "^/admin/?" ||
  req.url ~ "^/user" ||
  req.url ~ "^/user/.*$" ||
  req.url ~ "^/users/.*$") {
  return (pass);
 }

and the session cookies

if (req.http.Cookie) {
    set req.http.Cookie = ";" + req.http.Cookie;
    set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
    set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|NO_CACHE)=", "; \1=");
    set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=", "; \1=");

If I try to login directly from apache port:8000 it works as expected. Here's the whole default.vcl file: http://pastebin.com/qPRyFEjP

I don't get why it's not piping to the authenticated users. Why wouldn't it login in? Thanks.

2 Answers 2

3

The offending parts in your VCL are (line 53):

# Drop any cookies sent to Drupal.

 if (!(req.url ~ "install\.php|update\.php|cron\.php|admin\.php")) {
 unset req.http.cookie;
 }

and (line 81):

# Drop any cookies Drupal tries to send back to the client. This will make it unpossible to login, unless you filter it a bit better that it is made below
sub vcl_fetch {
 if (!(req.url ~ "install\.php|update\.php|cron\.php|admin\.php")) {
  unset beresp.http.set-cookie;
 }
}

Remove both of them.

4
  • There is more to this somewhere. It logs in but node/add or any other path besides /users/* goes to access denied, even on user 1 and then varnish won't seem to cache pages any more. No more "hits"
    – user20594
    Commented Nov 1, 2014 at 15:17
  • Indeed, there is another snipped which is obviously wrong.
    – znerol
    Commented Nov 1, 2014 at 19:07
  • But the response headers now state X-Varnish-Cache MISS
    – user20594
    Commented Nov 1, 2014 at 20:17
  • It's caching the frontend now, but the issue remains the same. It doesn't login unless directly using apache port. When trying to add content using the frontend theme logs out..
    – user20594
    Commented Nov 16, 2014 at 17:46
1

I had the same issue and the solution was to explicitly set the cookie domain for the Drupal website in settings.php. For example:

 $cookie_domain = '.mydomain.com';

This way Drupal will store the session cookie correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.