Welcome! Log In Create A New Profile

Advanced

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

Maxim Dounin
July 21, 2011 07:54AM
Hello!

On Thu, Jul 21, 2011 at 06:45:00AM -0400, ilya wrote:

> I have Nginx set up to proxy_pass requests to location /api to
> 127.0.0.1:3000, 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.

How cookies are set? I.e. please show Set-Cookie header from
nginx (or backend) response. I suspect domain attribute doesn't
match hostname of your nginx server, and that's why cookies are
rejected by browsers.

> 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;
> server_name 173.203.105.235;
>
> root /home/project/public;
> location ^~ /api/ {
> proxy_pass_header Set-Cookie;
> proxy_pass_header P3P;

Just a side note: these "proxy_pass_header" directives aren't
needed.

> proxy_pass http://127.0.0.1:3000;
> }
> }
> }

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

ilya July 21, 2011 06:45AM

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

Maxim Dounin July 21, 2011 07:54AM

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

ilya July 21, 2011 11:18AM

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

Maxim Dounin July 21, 2011 11:36AM

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

ilya July 21, 2011 11:45AM

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

Maxim Dounin July 21, 2011 12:14PM

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

ilya July 21, 2011 12:28PM

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

Maxim Dounin July 21, 2011 04:54PM

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

ilya July 21, 2011 08:03PM

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

jzabel May 10, 2012 12:45PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 113
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready