redsocks
redsocks copied to clipboard
Automatic failover in case of proxy-server failure
Hi @darkk
I have 3 socks5 proxies that I create with:
ssh -D 1080
ssh -D 1081
ssh -D 1082
Can I use redsocks to load balance those proxies ? perhaps I can configure the redsocks.conf
to be something like this ?
redsocks {
local_ip = 127.0.0.1;
local_port = 11080;
ip = 127.0.0.1;
port = 1080;
port = 1081;
port = 1082;
type = socks5;
}
If I can't, do you have an idea on how to do this ?
You can configure several local_ports to match several different ports like that:
redsocks {
local_ip = 127.0.0.1; ip = 127.0.0.1; type = socks5;
local_port = 11080;
port = 1080;
}
redsocks {
local_ip = 127.0.0.1; ip = 127.0.0.1; type = socks5;
local_port = 11081;
port = 1081;
}
redsocks {
local_ip = 127.0.0.1; ip = 127.0.0.1; type = socks5;
local_port = 11082;
port = 1082;
}
And now the trick is to do proper load balancing as definition of «proper» varies a lot. I don't know if simple randomized load balancing is OK for you, but it can be implemented like that
iptables … -m random --mode random --probability 0.3333333333 -j REDIRECT --to-ports 11080
iptables … -m random --mode random --probability 0.3333333333 -j REDIRECT --to-ports 11081
iptables … -j REDIRECT --to-ports 11082
I want to do dynamic load balancing, so first it has to check whether the first socks proxy is online, if it's not then skip that proxy and check the second one, if the second one is online then switch to that proxy, it should continuously do that, any ideas on how to achieve such a thing ?