Reputation: 625
I'm trying to have openresty to reverse proxy TCP dynamicaly using lua.
For the start, I have :
stream {
server {
listen 9291;
set_by_lua_block $proxy '
ngx.var.proxy = "10.128.128.3:8291"
';
proxy_pass $proxy;
}
}
But openresty -t says:
nginx: [emerg] "set_by_lua_block" directive is not allowed here in /usr/local/openresty/nginx/conf/nginx.conf:129
I found many docs on dynamic proxy_pass, but all for 'http'.
Upvotes: 1
Views: 1936
Reputation: 3064
Take a look at balancer_by_lua_block directive. You will need to use ngx.balancer API within balancer_by_lua_block.
Read all docs carefully. There are a lot of smart details. But all you need is here, just RTFM.
Upvotes: 1