TCP proxy in node.js

Use like this:

$ node proxy.js 9001 80

Or forwarding to remote host:

$ node proxy.js 9001 otherhost:80

Source (save as proxy.js):

The code used to be pasted here, but apparently Jekyll (the static blog generator) has a bug with it, so find the code from my answer at StackOverflow.