Saturday, January 8, 2022

[SOLVED] How to proxy httpd call using netcat (nc)

Issue

I have a proxy pass which redirects all BE service calls to the API-Gateway. For debugging one particular scenario, I want to proxy all urls with base path /abc to a netcat proxy which would dumplt the complete request on console.

ATM I am using following proxy pass:

ProxyPass /abc/ http://localhost:8089/apigateway/api/

Whereas I am listening on port 8089 as follow:

nc -p 8089 localhost 8080

But the nc connection is closing up within few seconds after i run the above mentioned command. Any idea what am I do wrong?

When I curl the url http://localhost/abc/messaage, I see 503 as response.


Solution

Following worked for me: sudo nc -l localhost 8089 < abc.txt | tee -a in | nc localhost 8080 | tee -a out.html > def.txt

Listening on port 8089 (httpd forwards everything on 8089). nc then forwards the request to port 8080 (actual apigateway). In the middle it dumps the request and response in different files.



Answered By - Obaid Maroof