lua-resty-core
lua-resty-core copied to clipboard
I use recreate_request in balancer_by_lua_block phase, but it never work.
I want to change request header in balancer_by_lua_block phase, because i need to pass host header to next upstream node. I use recreate_request function to change request header information but it doesn't work.
my test example show as follow:
`upstream apisix_backend {
server 0.0.0.1;
balancer_by_lua_block {
local balancer = require "ngx.balancer"
balancer.recreate_request()
ngx.var.domain_host="www.baidu.com"
}
keepalive 320;
}
`
` location / { set $upstream_host ''; proxy_set_header Host $upstream_host;
content_by_lua_block {
ngx.say("1");
}
} `
set header or var before recreate_request, like this:
server 0.0.0.1;
balancer_by_lua_block {
local balancer = require "ngx.balancer"
ngx.var.domain_host="www.baidu.com"
ngx.req.set_header("kk", "dasda")
balancer.recreate_request()
}
keepalive 320;