Phusion Passenger - Sticky session - 如何向 set-cookie header 添加选项?

Phusion Passenger - Sticky session - How to add options to set-cookie header?

在 Phusion Passenger 中启用粘性会话会在下一个表格中添加 set-cooke header:

Set-Cookie: _passenger_route=598708409; Path=/

问题:

  1. 如何修改Path
  2. 如何设置httpOnly选项?
  3. 如何设置secure选项?
  4. 如何设置其他选项?

这是设置 cookie 的relevant code

  1. Path 由 baseURI
  2. 控制
  3. httpOnly 未设置 for this reason: // Note that we do NOT set HttpOnly. If we set that flag then Chrome // doesn't send cookies over WebSocket handshakes. Confirmed on Chrome 25.
  4. & 4. 当前代码无法注入其他值。

路径设置为passenger_base_uri的值 httpOnly 未由 Passenger 设置,因为它会阻止在 Chrome 上通过 websockets 发送 cookie(最后确认于 Chrome 25)。

要设置 httpOnlysecure 和其他选项,也许使用 ngx_http_lua_module 中的 header_filter_by_lua_block 之类的东西可能会有用(这包含在 apt由 Phusion 提供的打包 nginx,否则可以作为 dynamic module 安装)。