Proxying to node.js + express.js, session doesn't persist
Maxim Dounin
mdounin at mdounin.ru
Thu Jul 21 16:13:03 UTC 2011
Hello!
On Thu, Jul 21, 2011 at 11:45:36AM -0400, ilya wrote:
> Well, not really, since this happens _only_ when nginx is used.
> I and other people use Express sessions and they work, but in my case
> nginx somehow breaks them. The fact that session becomes flaky with
> introduction of nginx doesn't mean Express is broken, it means that
> nginx introduces some change that affects session.
> On the backend, sessions stored in Redis.
Are you see sessions not being flacky while working directly with
your backend?
> Looking at my config - does nginx pass all the headers from browser and
> backend to each other? Maybe it modifies them somehow? Connect.session,
> that Express uses
> (https://github.com/senchalabs/connect/blob/master/lib/middleware/session.js)
> uses this for fingerprinting:
>
> ---
> function defaultFingerprint(req) {
> var ua = req.headers['user-agent'] || '';
> return ua.replace(/;?\schromeframe\/[\d\.]+/, '');
> };
> ---
>
> and gets existing session like so:
> ---
> // get the sessionID from the cookie
> req.sessionID = req.cookies[key];
> ---
>
> So, can it be that nginx constantly modifies UA or filters out cookies?
> Or anything else?
No, nginx doesn't modify neither User-Agent nor Cookie headers
unless explicitly asked (with proxy_set_header directive).
Maxim Dounin
More information about the nginx
mailing list