How do I direct SOCKS5 proxy traffic to other SOCKS5 proxies based on ports?

Linode Staff

If you can help point me in the right direction, it would be appreciated.

So I bought a bunch of premade SOCKS5 proxies from a provider, and I want to set up a single Linode VPS as a SOCKS5 proxy that can point to other proxies depending on the port.

This is my Linode server's IP address: xx.xxx.xx.xxx


I want socks5 connections to particular ports to be redirected to the socks5 proxies I bought.


For example, this way (randomly generated IP addresses for forwarded destination):
xx.xxx.xx.xxx:8000 -> 67.229.232.91:1080

xx.xxx.xx.xxx:8001 -> 2.80.200.206:1080

xx.xxx.xx.xxx:8002 -> 43.14.235.96:1080

xx.xxx.xx.xxx:8003 -> 114.232.168.4:1080

xx.xxx.xx.xxx:8004 -> 84.12.192.10:1080 and so on.

So for example, if I went on Proxifier on Windows:

if I connect to xx.xxx.xx.xxx:8001, i'd get 2.80.200.206 on whatsmyip.com.

if I connect to xx.xxx.xx.xxx:8003, i'd get 114.232.168.4 on whatsmyip.com.

The point of this is to make proxy management easier for my use case.
I have a lot of proxies that I need to replace in a tedious GUI on a Windows software.
It gets hard to manage, so my end goal is to have a setup like this,
in a way that I can have a simple text file in the format:

xx.xxx.xx.xxx:8000-> proxy1:port

xx.xxx.xx.xxx:8001-> proxy2:port

xx.xxx.xx.xxx:8003-> proxy3:port, etc.

This way, I'd set up that static ip on the GUI software, only once and don't touch it again. I want to have a central proxy list text file to deal with this in one place. To do any replacements, I'd go edit my text file.

xx.xxx.xx.xxx:8001

xx.xxx.xx.xxx:8002

xx.xxx.xx.xxx:8003 etc.


Eventually I could make it be a web database, but that's finishing touches. Ideally, replacing any proxy in this file would not make other connections be disconnected.


So I assume I'll have to write a program for this part, to keep each connection isolated from each other, unless there's something already made.


It seems like a very simple concept though, I would be surprised if nothing already exists in open source for this.

I see proxy companies sell "backconnect" SOCKS5 proxies, which is this exact same setup. 
But no results on how they accomplish this, and the fact that I need SOCKS5 makes it harder to find relevant results.


Also, the proxies I buy are premade, so you can only access them as SOCKS5 proxy.
They don't allow SSH access so I can't go into each server and install additional software.


Please, let me know if you happen to know any information on this/what tools to research.

Thank you

1 Reply

Admittedly, I’m not very familiar with SOCKS5, so I apologize if the information that follows doesn’t fully encompass what your goal is.

It seems like you want to create a SOCKS5 proxy chain, but you want to make it dependent on the ports that are accessed. While I wasn’t able to find any resources that would directly apply, I saw that you mentioned using Proxifier on Windows to achieve something similar. I was able to gather a few resources that were indicated as Linux-based alternatives to Proxifier:

http://darkk.net.ru/redsocks/https://github.com/haad/proxychainshttps://github.com/darkk/redsocks

I also found other resources that may help you in your endeavors:

https://www.proxyrack.com/how-to-chain-socks5-proxies-and-setup-using-srelay-on-ubuntu-16/
https://github.com/shadowsocks/shadowsocks-libev/issues/2459
https://superuser.com/questions/1213774/proxy-chaining-how-does-it-exactly-work

Please use these tools/resources at your own discretion as I didn’t personally test them myself.

My colleague also mentioned an alternative just in case you wanted to ditch SOCKS5, which you’re probably pretty set on doing, but I’ll throw it in here anyway. NGINX reverse proxy will forward the request to the IP and then the IP will forward back the data to the user through the proxy, keeping the backend server’s true IP hidden. For more information on NGINX reverse proxy, please refer to NGINX official documentation: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

We also have a guide on configuring NXGINX reverse proxy: https://www.linode.com/docs/web-servers/nginx/use-nginx-reverse-proxy/#configure-nginx

Best of luck!


Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct