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.

1

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.

  • 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 Nov 1 '14 at 15:17
  • Indeed, there is another snipped which is obviously wrong. – znerol Nov 1 '14 at 19:07
  • But the response headers now state X-Varnish-Cache MISS – user20594 Nov 1 '14 at 20:17
  • If this is fixing the login problem, then please accept the answer and then post a new question for the new problem. – znerol Nov 3 '14 at 8:33
  • 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 Nov 16 '14 at 17:46
0

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, privacy policy and cookie policy