I have a web server listening at 8080, I want to use the nc
command to listen at port 80, so all incoming request and outgoing response are logged into two files, namely inflow
and outflow
.
I have followed the link at http://smaftoul.wordpress.com/2009/05/13/netcat-as-a-logging-tcp-proxy/, not work as expected.
cat proxypipe | nc -l -p 80 | tee -a inflow | nc localhost 81 | tee -a outflow 1>proxypipe
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port]
[-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]
[-x proxy_address[:port]] [hostname] [port[s]]
Best Answer
Take a close look at the help output netcat is giving you
The
-p
option to netcat species the source port, which you generally don't care about. If you remove the-p
, it should work just fine:At least, this will make netcat listen for connections on port 80. Whether this will make your logging proxy work or not I can't say.