subrequests - huge body, mirror response from proxy_pass

v_label nginx-forum at forum.nginx.org
Fri Mar 6 16:13:06 UTC 2020


Hi all. 
I want to mirror a response from 'proxy_pass` backend. I need to send it not
only back to a client but also to one more service.
I was thinking to make it by subrequest in a filter module.

There is a problem with sending subrequest body.
1) I can get a response body by 'ngx_http_read_client_request_body'  or
2) I can wait for the last chain in a filter body and just save all body
chunks.
and then send it as a subrequest body.
Both approaches work.

But the problem is that some response bodies are big(several Gb), 
and keep whole body in RAM is not efficient.

Is there a way to send subrequest body gradually by chunks in the process of
receiving them from 'proxy_pass' backed ? I need smthg like
ngx_http_proxy_module does when it is sending a response to an upstream but
for subrequest.
Any ideas? Thanks.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287272,287272#msg-287272



More information about the nginx mailing list