How to set proxy_http_version in LUA code before upstreaming the request in nginx

前端 未结 1 715
太阳男子
太阳男子 2021-01-23 09:51

I want to change the proxy http version in Lua code programmatically. Is there any way?

Yes, I know that we can set it via the nginx config file in the l

相关标签:
1条回答
  • 2021-01-23 10:42

    Updated 14.10.2020

    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;
       ...
    }
    
    0 讨论(0)
提交回复
热议问题