I can access a web page just fine by directly hitting my web server as follows:
$ echo "GET /sample" | nc web-server 80
This is contents of /sample...
$
Now, I would like netcat to go via a Squid HTTP proxy (listening on port 3128), much like I can configure my Firefox browser via its proxy preferences and have it go via an HTTP proxy.
I tried the following, but it did not work:
$ echo "GET /sample" | nc -x squid-proxy:3128 web-server 80
<Seemed to be blocked FOREVER on input, so I killed it.>
<Ctrl-C>
$
Note: I'm using RHEL 5.3 version of netcat that has the following options:
$ nc --help
nc: invalid option -- -
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
[-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
[-x proxy_address[:port]] [hostname] [port[s]]
Excerpt from the man page of nc
:
EXAMPLES
<snip>
Connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4, port 8080.
This example could also be used by ssh(1); see the ProxyCommand directive in
ssh_config(5) for more information.
$ nc -x10.2.3.4:8080 -Xconnect host.example.com 42
Now, because mine is not an ssh/SSL usecase, I'm not sure how to use the -x
/ -X
options, or even whether I should be using them at all!
If there's more than one way to achieve the above goal (namely, routing netcat traffic via an HTTP proxy), then I would greatly appreciate if you could share them all.
Many thanks in advance.