Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic failover in case of proxy-server failure #94

Open
hillz1 opened this issue Dec 26, 2016 · 2 comments
Open

Automatic failover in case of proxy-server failure #94

hillz1 opened this issue Dec 26, 2016 · 2 comments

Comments

@hillz1
Copy link

hillz1 commented Dec 26, 2016

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 ?

@darkk
Copy link
Owner

darkk commented Dec 27, 2016

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

@darkk darkk mentioned this issue Dec 27, 2016
@hillz1
Copy link
Author

hillz1 commented Dec 28, 2016

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 ?

@darkk darkk changed the title How to run redsocks with multiple SOCKS5 proxies Automatic failover in case of proxy-server failure Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants