openresty / stream-lua-nginx-module

Embed the power of Lua into NGINX TCP/UDP servers
BSD 2-Clause "Simplified" License
725 stars 199 forks source link

content_by_lua_block not working with tcp proxy_pass. #295

Closed anand-010 closed 2 years ago

anand-010 commented 2 years ago

Hello I am new to nginx and openresty. I am trying to dynamically route tcp connections. But content_by_lua_block doesn't seems to be working in tcp proxy_pass configuration however it worked with example http configuration.

error_log logs/error.log;
events {
    worker_connections 1024;
}

stream {
    # define a TCP server listening on the port 8080:
    server {
        listen 8080;
        set $target '';
        content_by_lua_block {
            ngx.var.target = "127.0.0.1:7000"
        }
        proxy_pass $target;
    }
}

But when i tried to add set $target "127.0.0.1:7000"; It's working. I've also tried to paste it inside location / {} but it also not working. Please help me.

anand-010 commented 2 years ago

Moving to main repository.