如何在stunnel后面的node.js / connect应用程序中设置req.connection.proxySecure

我们有一个node.js / express应用程序,位于stunnel后面,用于ssl终止。 我无法弄清楚如何强制安全的会话cookie。 看着会话中间件源:

// only send secure session cookies when there is a secure connection. // proxySecure is a custom attribute to allow for a reverse proxy // to handle SSL connections and to communicate to connect over HTTP that // the incoming connection is secure. var secured = cookie.secure && (req.connection.encrypted || req.connection.proxySecure); if (secured || !cookie.secure) { res.setHeader('Set-Cookie', cookie.serialize(key, req.sessionID)); } 

我显然必须将req.connection.proxySecure设置为true,但我不知道该怎么做。 看来stunnel应该通过这个“通过HTTP”,但stunnel不能设置标题。 所以我不知所措 我应该尝试在会话中间件之前通过自定义位中间件在本地设置它,还是在某处连接configurationvariables?

谢谢你的帮助

确保代理正在设置X-Forwarded-Proto: https标题。 然后,您必须将proxy:true config参数添加到会话中间件。