Create HTTP proxy using netcat?

1

Is it possible to use nc as an HTTP proxy? I'm hoping to use nc on a VPS as an HTTP proxy and configure my browser to use the netcat server. Is this possible?

A few results for googleing "netcat http proxy" but not quite what I'm trying to do. These configurations seems to first accept netcat connections then proxy them out to another netcat listener. I need netcat to proxy out, similar to a SOCKS5 proxy.

https://stackoverflow.com/questions/4053876/using-netcat-nc-as-an-http-proxy-server-and-monitor

https://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html

user908559

Posted 2018-05-25T03:15:24.110

Reputation: 13

1What’s your reason for wanting to use netcat instead of say an open source HTTP proxy package? – Spiff – 2018-05-25T03:47:31.720

@Spiff just having some fun with netcat. also thought it might be simpler than using something fully featured like squid? do you know if what im trying to do is possible? – user908559 – 2018-05-25T04:00:10.207

Why would it be simpler? Dedicated proxy software exists for a reason — there are more things to do rather than just forwarding bytes over an interface. – slhck – 2018-05-25T04:26:46.907

This may be of use to you. https://unix.stackexchange.com/questions/38783/how-to-make-netcat-use-an-existing-http-proxy

– Tim_Stewart – 2018-05-25T12:16:12.713

And this: https://serverfault.com/questions/405822/how-do-i-use-socat-as-a-proxy-server

– Tim_Stewart – 2018-05-25T12:17:54.757

Answers

2

I'm pretty sure you can't use netcat as a (general purpose) http proxy. Here's why:

Netcat is like telnet in as much as it creates a tcp connection to a known endpoint. Unfortunately this presents 2 obstacles to using it as an HTTP proxy-

  1. It has a static end connection, so it does not know which IP address to connect to.
  2. The HTTP 1.1 protocol - which is the one in common use adds a header line within the request to say which website to get. Netcat is not designed to extract this header and make a connection out using it.

davidgo

Posted 2018-05-25T03:15:24.110

Reputation: 49 152