Calling proxy_pass from within a .lua file

31 views
Skip to first unread message

Timothy Gallagher

unread,
Dec 1, 2016, 1:42:36 PM12/1/16
to openresty-en
Hello all, I am wondering if I can set proxy_pass from within a content_by_lua_file or better yet a .lua file ?  I know that I can set a FQDN/IP to a ngx.var.variable and then set proxy_pass $variable.  This I know, what I am looking for is to perform the proxy_pass in a lua file.

Thanks for the help,
Agoli

Robert Paprocki

unread,
Dec 1, 2016, 3:31:22 PM12/1/16
to openre...@googlegroups.com
Hi,

On Thu, Dec 1, 2016 at 10:42 AM, Timothy Gallagher <golgoap...@gmail.com> wrote:
Hello all, I am wondering if I can set proxy_pass from within a content_by_lua_file or better yet a .lua file ?  I know that I can set a FQDN/IP to a ngx.var.variable and then set proxy_pass $variable.  This I know, what I am looking for is to perform the proxy_pass in a lua file.

proxy_pass is an Nginx config directive; it cannot be used as part of any *_by_lua handler. Additionally, proxy_pass and content_by_lua handlers conflict; you cannot have both Nginx (via Lua) determine the response content, and do so via proxy pass (see https://github.com/openresty/lua-nginx-module#content_by_lua).

If you're trying to dynamically determine which backend to use, perhaps have a look at balancer_by_lua (https://github.com/openresty/lua-nginx-module#balancer_by_lua_block)?
Reply all
Reply to author
Forward
0 new messages