Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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]]
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Take a close look at the help output netcat is giving you

usage: ... [-p source_port] ...
       ... [hostname] [port[s]]

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:

nc -l 80

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.