openresty / openresty/stream-lua-nginx-module
Want to add a life time limit for stream proxy_pass session with stream-lua-nginx-module.
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 749
- Forks
- 210
- Avg merge
- 4h 31m
- Merged PRs (30d)
- 3
Description
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;
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided stream configuration, especially preread_by_lua_block, ngx.timer.at, ngx.exit, and proxy_pass, and reproduce the reported behavior. Read the stream-lua-nginx-module guidance for session lifecycle and timers; the work is complete when a documented, reliable approach enforces the requested maximum session duration and closes the proxied session.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100