PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 14, 2022

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

 September 14, 2022     lua, nginx, nginx-location, nginx-reverse-proxy, openresty     No comments   

Issue

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 location/server block. Is there any way that I can do it using Lua dynamically per request?


Solution

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;
   ...
}


Answered By - Alexander Altshuler
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing