Proxying to node.js + express.js, session doesn't persist

Maxim Dounin mdounin at
Thu Jul 21 20:52:27 UTC 2011


On Thu, Jul 21, 2011 at 12:28:39PM -0400, ilya wrote:

> > Are you see sessions not being flacky while working directly with
> > your backend?
> Correct. I've tested backend standalone and this doesn't happen. Notice,

So try to figure out what goes wrong.  Dumping all of a session 
requests till session break may be helpful, as well as dumping all 
of the requests between nginx and your backend.

Instrumenting your backend's code may be helpful as well (or even 

> that in requests above connect.sid is changing every request. That is
> not supposed to happen - with standalone backend connect.sid value is
> constant across requests and changes either when user re-logins or it
> expires.

All of the requests you've provided have identical connect.sid as 
far as I see.

> Can it be because nginx talks HTTP/1.0 to backend?.. Ugh.

This may be a problem if e.g. your backend is multi-process, while 
session store is local to process.  With HTTP/1.1 and keepalive 
you'll be most likely talking to one process over established 
connection (and everything seems to work ok), while though nginx 
there will be new connection to your backend for each request and 
you'll be talking to many backend processes (and you'll see 
"flacky" sessions as described).  This is a typical example of 
"something wrong with session storage on backend side" as 
mentioned in previous message.

Maxim Dounin

More information about the nginx mailing list