express.js sessions with reverse proxy express.js sessions with reverse proxy express express

express.js sessions with reverse proxy


Add the following to server.js

app.enable('trust proxy');

Quote from ExpressJS API Docs: http://expressjs.com/api.html#app-settings ...

trust proxy - Enables reverse proxy support, disabled by default


Judging by Apache ProxyPass and Sessions This apache config Maybe ...

<VirtualHost *:80>    ServerName api.mydomain.com       ProxyPass / http://localhost:2000/    ProxyPassReverse / http://localhost:2000/    ProxyPassReverseCookiePath / /</VirtualHost>


It should be trivial to look at the session cookie being forwarded and see why your browser doesn't re-send it when proxied -- the domain or path are likely wrong.

Re: your later comments -- Maybe you really did set "ProxyPassReverseCookieDomain / /" instead of using domains as the argument?

ProxyPreserveHost would probably also indirectly work for you, but fixing up the cookie is better.