1

I have made a simple TCP proxy that rewrtites requests using netcat like so:

nc -q -1 -k -l 8080 < myfifo | sed -u 's/something/something_else/' | nc -q -1 example.com 80 > myfifo

However, when clients try to connect through the proxy, some (but not all!) just time out. What am I missing?

Edit: I am using the OpenBSD version of netcat.

  • How is this suppoesed to work? Please add your thinking. – wurtel Jan 31 '18 at 08:29
  • The intent here is to make a simple proxy. A fifo buffer called myfifo is created. the first nc should listen for connections on port 8080. Requests are passed through sed to change the desired content, and then are passed to the destination server on port 80 with the second nc command. Responses from the destination are written to myfifo, which is redirected back to the first nc command, which returns the (unmodified) response to the client. What gets me is that some of the connections make it through, following the expected behavior, but other similar ones just time out. –  Feb 01 '18 at 23:15
  • Ah OK, my version of netcat doesn't have the `-k` option, and I was confused about netcat reading from the socket and from standard input, but I get it now. It may be due to some buffering somewhere, probably in sed. – wurtel Feb 02 '18 at 09:32
  • That's a good point, I've updated the question to show what version of netcat I'm using –  Feb 04 '18 at 05:54

0 Answers0