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

ilya nginx-forum at
Thu Jul 21 10:45:00 UTC 2011

I have Nginx set up to proxy_pass requests to location /api to, where Node.js is listening.
Node.js is running a server written with Express.js.
In my previous project, I used request session in Express to track
users. In that project, I didn't use Nginx.
In the current project, I can't use session because it simply doesn't
save. I can write and read cookies, but not the request session. I
verified that the issue is in Nginx by running exact same code without
Nginx and being able to use request session.
My nginx.conf is as follows:

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    gzip  on;

    server {
        listen 80;

        root /home/project/public;
        location ^~ /api/ {
            proxy_pass_header Set-Cookie;
            proxy_pass_header P3P;

Posted at Nginx Forum:,212747,212747#msg-212747

More information about the nginx mailing list