在nginx中上游请求之前如何在LUA代码中设置proxy_http_version
How to set proxy_http_version in LUA code before upstreaming the request in nginx
我想以编程方式更改 Lua 代码中的代理 http 版本。有什么办法吗?
是的,我知道我们可以通过 nginx config 文件在 location/server 块中设置它。有什么方法可以根据请求动态使用 Lua 来做到这一点?
2020 年 10 月 14 日更新
location / {
content_by_lua_block {
-- some logic here
if flag then
return ngx.exec("@http1_0")
end
return ngx.exec("@http1_1")
}
}
location @http1_0 {
proxy_pass ...;
proxy_http_version 1.0;
...
}
location @http1_1 {
proxy_pass ...;
proxy_http_version 1.1;
...
}
我想以编程方式更改 Lua 代码中的代理 http 版本。有什么办法吗?
是的,我知道我们可以通过 nginx config 文件在 location/server 块中设置它。有什么方法可以根据请求动态使用 Lua 来做到这一点?
2020 年 10 月 14 日更新
location / {
content_by_lua_block {
-- some logic here
if flag then
return ngx.exec("@http1_0")
end
return ngx.exec("@http1_1")
}
}
location @http1_0 {
proxy_pass ...;
proxy_http_version 1.0;
...
}
location @http1_1 {
proxy_pass ...;
proxy_http_version 1.1;
...
}