NGX LUA 可以在 set_by_lua 阶段读取到源站的 response header 里的 Set-Cookie 值么?

2014-05-13 10:24:56 +08:00
 Livid
6207 次点击
所在节点    NGINX
4 条回复
xoxo
2014-05-13 11:42:02 +08:00
LazyZhu
2014-05-13 12:25:44 +08:00
我记得好像不行吧,ngx.location.capture / ngx.socket 是不能在 set_by_lua 里面用的
fghzpqm
2014-05-13 19:24:47 +08:00
不行,set_by_lua 是运行在 rewrite 阶段,并且:

『This directive is implemented by injecting custom commands into the standard HttpRewriteModule's command list. Because HttpRewriteModule does not support nonblocking I/O in its commands, Lua APIs requiring yielding the current Lua "light thread" cannot work in this directive.』

http://wiki.nginx.org/HttpLuaModule#set_by_lua
Livid
2014-05-28 13:24:12 +08:00
貌似今天刚刚发布的 1.7.1 里可以了:

http://nginx.org/en/docs/http/ngx_http_upstream_module.html

$upstream_cookie_name
cookie with the specified name sent by the upstream server in the “Set-Cookie” response header field (1.7.1). Only the last server’s response header fields are saved.

一会试验一下。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/112287

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX