Hey folks,
Is there any plan to support usage of ngx.redirect() in body_filter_by_lua_block()?
For a project I am working on, I need to be able to send redirect responses (3XX) to the client based on analysis of the data received from upstream (of course, before I start streaming/letting the upstream response /flow through to the client) from within a body filter.
It may be because I am new to nginx but at first glance it doesn't seem to be straight-forward. I suspected the lack of support for ngx.redirect() within body_filter_by_lua_block() is for the same reason.
If so, any expert suggestions on how best to tackle the situation?
My half-baked (yet to think through it thoroughly) idea is to -
1. Hold back from sending out upstream response headers in the header filter, analyze the upstream response body in the body filter & if required to redirect,
2. Overwrite the headers held back to have a 3XX status code & set the location header, send it out & somehow
3. Close the upstream connection & clean up things [easier to say, I know! Or is it in fact easy?]
Thanks,
Rohit