I have set up an nginx proxy with Openresty. The proxy takes up an HTTP SOAP POST request, modifies it by using a LUA script written within the root location ("/") of the HTTP server on port 8080, and sends it to a backend server for processing, which works correctly.
When the proxy relays the connection to the backend server, it creates a new connection, as per TCP specs, generating a new source port different from port 8080, where the backend server should respond.
Is there a way to intercept the response on nginx, so that it'll be able to intercept such response and modify it accordingly, with a LUA script?
Thanks for any insights you may be able to provide.
Here is the example based on my previous answer:
If your response body is large enough, things can be more complicated because response processed by parts (by data chunks in nginx terminology).