7

Is there any command line tool can be used to convert a Socks5 proxy to HTTP proxy?

I searched for an answer from 2015 that said I could use Polipo, but it has been discontinued.

Is there any other tool can do it? Thanks a lot.

3
  • converting SOCKS5 to HTTP is not possible without some level of software manipulation, because they speak completely different languages. Why do you need to convert these? Are you unable to set your system to just point directly to the HTTP proxy instead?
    – Thomas Ward
    Nov 20, 2021 at 21:30
  • @ThomasWard have a SOCKS5 proxy, and my Synology NAS do not support SOCKS5 proxy, so I have to convert the SOKCS5 proxy to HTTP proxy.
    – Yongyi
    Nov 22, 2021 at 6:19
  • so to confirm, Synology needs to connect over an HTTP proxy, which then needs to hand off to a SOCKS5 proxy, correct? Just so I know how to phrase my answer properly.
    – Thomas Ward
    Nov 22, 2021 at 18:07

3 Answers 3

10

This can be done with gost, which can serve proxies using many proxy protocols and tunnel traffic through to others.

$ gost -L=http://:8080 -F=socks5://proxy.domain.name:1080
7

Basically, SOCKS5 and HTTP speak completely different languages, so you can't just 'convert' a SOCKS5 to an HTTP proxy. You need to run some kind of intermediate software that will handle the handoff between the two proxies.

NOTE: This is an untested solution because I have no proxies on my network for testing. However, the concept and configuration appears to be sound for proxying proxy traffic, though again this is untested.

There is a project out there called python-proxy (pproxy is the executable). It is not my project, but it seems like this is capable of doing proxy-to-proxy conversion and handoff.

To start, install this on whichever system is going to run your HTTP proxy that Synology can talk to, even if it's on your SOCKS5 proxy server. Install python3-pip first so you can use PyPI projects and software:

sudo apt install python3-pip
sudo pip3 install pproxy[accelerated]

This will install the Python proxy tool system wide, and have C-library integrations that will improve performance. If for some reason this doesn't install properly, then just use the plain pproxy tool after making sure you remove pproxy accelerated first (just say yes if it prompts at uninstall, if it says its not installed then just do the install command):

sudo pip3 uninstall pproxy
sudo pip3 install pproxy

NOTE: I'm assuming that the connection is your Synology to an HTTP proxy, and then you want to hand the HTTP proxy stuff off to a SOCKS5 proxy. You can clarify in response to my comment on your question and I will alter this answer accordingly.

Then, theoretically, you would use this to run it on the system that will 'host' this 'http to socks5' proxy tool:

pproxy -l http://0.0.0.0:8080 -ru socks5://socks5.proxy.ip.or.domain:port

You would then point your Synology NAS to the http address and port combo for the system running the tool (if that server running pproxy has IP 10.20.30.40 then you would point the NAS at http://10.20.30.40:8080 for the proxy)

This should, in theory, handle the 'proxy handoff' between two different proxy types.

Again, I have not tested this, but the code and proxy theory do appear to be sound.

0

How I solved this:

  1. Install tsocks package (very useful tool on its own) and configure it for using your SOCKS5 proxy - this allows to tunnel some programs like apt via SOCKS5 (although not everything will work)
  2. Install tinyproxy-bin package, default configuration file example can be found at https://tinyproxy.github.io ; There is also tinyproxy package, but I only needed tinyproxy binary.
  3. Run tsocks tinyproxy -d -c ~/tinyproxy.conf (example that will not daemonize and assumes that the sample configuration file is created in home directory)

Alternatively, you may try different options (tinyproxy package, daemonize) but I didn't test them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .