I don't know if this a nginx problem, or a drupal side problem, but i'm using this module with nginx and it works, but my users are getting logged out on the website, or are logged in, but only after going to /user/login.

I do notice a pattern:
Uncached page: Anonymous users hits page, cached version gets created and proceeds to logon.

Cached pages: The user access the cached pages and it looks like he is logged out, but in reality he's still logged in.(session cookie still in the headers), yet the page shows the login form and no adminmenu on top.

Only pages NOT hit by a Anonymous users are normal, once the Anonymous has hit the page, the logged in user shows logged out.

Headers:
http://imgur.com/a/U4ub9

Dont know where to search for the fault...

The relevant nginx config:

location / {
other drupal nginx logic, not effected by boost

## First we try the URI and relay to the @cache if not found.
try_files $uri @cache;

}

#boost cache begin
## We define a named location for the cache.
location @cache {
    ## Boost compresses can the pages so we check it. Comment it out
    ## if you don't have it enabled in Boost.
    gzip_static on;

    ## Error page handler for the case where $no_cache is 1. POST
    ## request or authenticated.
    error_page 418 = @rewrite;

    ## If $no_cache is 1 then it means that either we have a session
    ## cookie or that the request method is POST. So serve the dynamic
    ## page.
    if ($no_cache) {
        return 418; # I'm a teapot/I can't get no cachifaction
    }

    ## No caching for POST requests.
    if ($request_method = POST) {
        return 418;
    }

    # Now for some header tweaking. We use a date that differs
    # from stock Drupal. Everyone seems to be using their
    # birthdate. Why go against the grain?
    add_header Expires "Tue, 13 Jun 1977 03:45:00 GMT";
    # We bypass all delays in the post-check and pre-check
    # parameters of Cache-Control. Both set to 0.
    add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
    # Funny...perhaps. Egocentric? Damn right!;
    add_header X-Header "Boost Helás Avril 1.0";
    ## Boost doesn't set a charset.
    charset utf-8;

    # We try each boost URI in succession, if every one of them
    # fails then relay to Drupal.
    try_files /cache/normal/$host${uri}_${args}.html /cache/perm/$host${uri}_.css /cache/perm/$host${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html @rewrite;
}
#boost cache end

Also, i use memcached for the session storage, but the problem also occurs without memcached involvement...

Thanks for your time.

Comments

demon326 created an issue. See original summary.

demon326’s picture

Issue summary: View changes
demon326’s picture

Title: Nginx: User getting logged out » Cached page, even for logged in user(nginx)
Component: User interface » Caching logic
ajayg’s picture

I am seeing the same issue with apache. SO this is not ngnix only, What baffles me , this was working fine till very recently today and no longer now. Other symptoms are same.

ajayg’s picture

Title: Cached page, even for logged in user(nginx) » Cached page, even for logged in user(nginx,apache)
Issue tags: +Apache
Bandy’s picture

Hi, here are my config with nginx 1.11.10 and Plesk:

location ~ / { #this try to find file but if there is not it activates @cache section
try_files $uri @cache;
}
location @cache { #this try to find if cache file exists
if ($http_cookie ~ "DRUPAL_UID") { return 405; }
if ($request_method !~ ^(GET|HEAD)$ ) { return 405; }
error_page 405 = @drupal;
gzip on;
add_header Expires "Tue, 22 Sep 1974 08:00:00 GMT";
add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
add_header X-Header "Boost Helás Avril 1.0";
charset utf-8;
try_files $uri /cache/normal/$host/${uri}_${args}.html;
}
location = / {
	if ($http_cookie ~ "DRUPAL_UID") { return 405; }
	if ($request_method !~ ^(POST|GET|HEAD)$ ) { return 405; }
	error_page 405 = @drupal;
        gzip on;
        add_header Expires "Tue, 22 Sep 1974 08:00:00 GMT";
        add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
        add_header X-Header "Boost Helás Avril 1.0";
        charset utf-8;
        try_files $uri /cache/normal/$host/_.html @drupal;
}
location @drupal {
	rewrite ^/(.*)$ /index.php?q=$1;
}

And all anonym User have the boost cache sites incl. Frontpage. Good Luck.

Edit: Config now with Expires, Cache-Control, X-Header and Charset.

ajayg’s picture

I moved my site to https and this issue seems to have resolved.