In order to set the headers of the upstream request, I use `ngx.req.set_header` in `rewrite_by_lua_block`, but my upstream endpoint cannot receive such header.
Author: HanobooCreated Feb 19, 2024Updated Dec 8, 2025
@agentzh I get a problem here.In order to set the headers of the upstream request, I use
ngx.req.set_headerinrewrite_by_lua_block, but my upstream endpoint cannot receive such header. here is my conf.upstream foo { server 127.0.0.1:6666 weight=1; } server { listen 8001; location / { rewrite_by_lua_block { ngx.req.set_header("Connection", "Upgrade") } proxy_pass http://foo; } } server { listen 8002; location / { proxy_set_header Connection ''; rewrite_by_lua_block { ngx.req.set_header("Connection", "Upgrade") } proxy_pass http://foo; } }request send by
8001port still cannot get the header "Connection: Upgrade"
Have you solved this problem?I have a similar problem,
Originally posted by @djfsb in https://github.com/openresty/lua-nginx-module/issues/437#issuecomment-948387694
Source: openresty/lua-nginx-module