Hi,
I am looking for a way to use nginx in order to inspect a response body and then return the response to the client's GET request based on the result of inspection.
I have investigated the sub module filter http://nginx.org/en/docs/http/ngx_http_sub_module.html, but the pattern implemented cannot be reused for my purpose.
I also investigated the example module https://www.nginx.com/resources/wiki/extending/examples/body_filter/, but I was not able to get this module to work. Returning an error code from the body filter is too late and the request gets stuck after the 200 header was already sent.
What I want to achieve is the following:
- Block a client request and perform the following inspection handler (could be an asynch handler)
- Receive the response header (do not forward it yet)
- Receive and inspect/parse the response body
- Depending on the result of the inspection: pass/fail
+ pass:
* send the response header to the client,
* send the response body buffers to the client
+ fail:
* send an error code response header to the client,
* discard the response body buffers
Thanks in advance
I am looking for a way to use nginx in order to inspect a response body and then return the response to the client's GET request based on the result of inspection.
I have investigated the sub module filter http://nginx.org/en/docs/http/ngx_http_sub_module.html, but the pattern implemented cannot be reused for my purpose.
I also investigated the example module https://www.nginx.com/resources/wiki/extending/examples/body_filter/, but I was not able to get this module to work. Returning an error code from the body filter is too late and the request gets stuck after the 200 header was already sent.
What I want to achieve is the following:
- Block a client request and perform the following inspection handler (could be an asynch handler)
- Receive the response header (do not forward it yet)
- Receive and inspect/parse the response body
- Depending on the result of the inspection: pass/fail
+ pass:
* send the response header to the client,
* send the response body buffers to the client
+ fail:
* send an error code response header to the client,
* discard the response body buffers
Thanks in advance