Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Want to add a life time limit for stream proxy_pass session with stream-lua-nginx-module. #346

Open
yasoo7964 opened this issue Apr 25, 2024 · 2 comments

Comments

@yasoo7964
Copy link

im making a reverce proxy with OpenResty,
wrote stream directive as below,
and then, i want to add a life time limit for each session like 1 hour max, 1min max ...
ChatGPT said to me 'ngx.exit() shutdown the sockets of proxy_pass' but it seemes it doesn't.
Any advice is appreciated.
thank you.
Best regard. yasoo7964

stream {
error_log /usr/local/openresty/nginx/logs/stream_error.log notice;
server {
listen 5432;
preread_by_lua_block {

                    local function ontimeout()
                            if premature then
                                    return
                            end
                            ngx.log(ngx.NOTICE, "Stream session timed out. Force close..")
                            ngx.exit(ngx.ERROR)
                    end

                    local ok, err = ngx.timer.at(60, ontimeout)
                    if not ok then
                            ngx.log(ngx.NOTICE, "Failed to create timer for a stream session. ", err)
                    else
                            ngx.log(ngx.NOTICE, "Start r-proxying a stream session.")
                    end
            }
            proxy_pass 192.168.62.222:5432;
    }

}

@zhuizhuhaomeng
Copy link
Contributor

This is currently not possible.

@yasoo7964
Copy link
Author

This is currently not possible.

Thank you, good to know that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants