我们有一个 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 无法设置标头。所以我很茫然。我应该尝试在会话中间件之前通过自定义中间件在本地设置它,还是在某处的连接配置变量中设置它?
谢谢你的帮助