Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have three proxy servers in my college, all of them are connected to three different service providers. At different instant of time, different proxies give different speed (depending the number of users using that proxy at that instant of time). I feel that changing the proxy server configuration in browser(or at any other network appl.) at different instant of time are very time-consuming. I want to write one script which can change the proxy server used by all of my network applications at different instant of time dynamically by doing some kind of test.

I am not able to start with it. Can somebody please give me some idea so that I can implement it.

share|improve this question
    
Just a hint into one possible (I suppose) direction, load-balancing might be a solution. Since you can't do this in your college's computers, you might have to do it locally. –  sr_ Apr 7 '12 at 17:24
    
Agree sr_, he could run something light like Inlab Balance and then just connect to loopback:8080 or whatever he sets it to. –  JodieC Apr 7 '12 at 20:20

4 Answers 4

Simple Solution

Set up a host alias for the proxy servers in your local hosts file, such as

192.168.1.1 chosenproxy #192.168.1.2 chosenproxy #192.168.1.3 chosenproxy

Now configure all applications to use this alias http://chosenproxy:8080

To then try different servers, just edit the IP address in the hosts file.

Manageable Port Solution

If you also need to change the port, use one of the light-weight proxy programs, such as polipo. Polipo runs by default on port 8123 so set every application to connect via polipo running locally, eg using the setting http://localhost:8123

Then to try a different proxy server, change the polipo configuration file (/etc/polipo/config) to specify the right Parent Proxy server and Port number, and restart polipo to activate the change.

share|improve this answer

You can use PROXY.PAC or WPAD.DAT

it's just an JavaScript, you can host this file on any web server in your intranet and set in client side http://webserever-ip/proxy.pac. using this script you can do load-balancing with your three proxy. also you can divide traffic using ip ranges in this java script , there are multiple feature like bypass intranet or any web site.

You can Setup this script Automatically in all your clients side , below option are required for the same

  • if You are using Domain Network then set Proxy.pac using Group Policy
  • You can set WPAD.DAT using DHCP
  • DNS
share|improve this answer

Assuming that you are using squid Two sibling proxies sharing the same visible name seems to do the trick for me. I have 2 set up with the names proxy1 and proxy2 respectively. The visible hostname is proxy. All you should have to do at that point is create an A record in dns for the name proxy with the IP addresses for proxy1 and proxy1. As long as they are set up as siblings in your squid.conf. Take a look here http://horms.net/projects/redundant_linux_paper/related/squid/hierarchies/concepts.html

share|improve this answer

To configure the proxy from a single point, you could set up a router that does destination address re-writing using an iptables rule such as

iptables -t nat -A PREROUTING -p tcp -d VIRTUAL_PROXY_IP --dport 80 -j NETMAP --to CURRENT_PROXY_IP

All applications and browsers would would use VIRTUAL_PROXY_IP as their proxy, which you would need to route through this special router. You change the rule as needed to change the CURRENT_PROXY_IP.

The advantage to this approach is that it is quick to set up and easy to administer. The disadvantage is that there is likely to be some disruption to some users who have sessions open (depending on the type of sessions and the type of upstream proxies). You also have to either write your own script to change the proxies, or change manually.

A better solution, suggested by sr_'s comment, would be to set up a load balancer. Consider LVS or HAProxy

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.