I want to use netcat as a proxy to log http requests and responses to files, then tail these to inspect traffic. Think wireshark.
Tried the following where 'fifo' is a named pipe, 'in' and 'out' are files, netcat proxy on port 8080, server on port 8081.
while true; do cat fifo | nc -l -p 8080 | tee -a in | nc localhost 8081 | tee -a out 1>fifo; done
Netcat stop responing after first request (while loop ignored?).
Netcat fails with msg
localhost [127.0.0.1] 8081 (tproxy) : Connection refusedif server unavailable on 8081. Question: Is it possible to "lazily" connect to 8081 when request is made? I.e. I do not want to have 8081 running when netcat is started.