http {
server {
listen 80;
location / {
content_by_lua_block {
local httpc = http.new()
httpc:request_uri("localhost:8080/test.html", {
method = "GET",
headers = {
["myheader"] = "myheadervalue",
}
}
}
}
}
server {
listen 8080;
location / {
content_by_lua_block {
local myheader = ngx.var.http_myheader -- can't get it ..
}
}
}
}
然后从curl 发起对80的请求,我发现在8080server块中获取不到从lua-resty-http客户端自定义的头部,我不知道这是合理的行为还是我的使用方式有问题。
业务场景: 从80接收到客户请求后需要进行拆解并通过cosocket发起请求到同一个openresty的不同server上完成相关任务,但是在8080上需要通过加入的头部进行业务处理。