1

I want to setup a Squid reverse proxy that splits HTTP traffic to two web servers for load balancing, and have it use persistence (so if a user gets to webserver1 with a first request their second request goes to webserver1 also.)

Other reverse proxy solutions I've worked with have done this by injecting a session cookie into the HTTP stream; how can I do this using squid?

2 Answers 2

1

Say your servers are at 10.0.0.51 and 10.0.0.52. You'll want something like this:

cache_peer 10.0.0.51 parent 80 0 no-query originserver sourcehash cache_peer 10.0.0.52 parent 80 0 no-query originserver sourcehash 

It'll do a hash of the client's IP address and direct a given client to the same upstream server with each request (as long as the upstream servers stay up) based on that.

2
  • Two problems with this: 1. (Not a biggie) Large organizations that NAT to a single IP outside will end up on the same web server; 2. (More serious) Clients that change IPs during a single session will break. Commented Apr 15, 2011 at 5:40
  • @ynguldyn Yup, cookie-based routing is more reliable and provides more consistently balanced client distribution, but I don't believe that it's supported by Squid? Depending on the application and the target users, this may work just fine for his needs. IP hashing is the best recommendation that I've got when the scope is limited to Squid. Commented Apr 15, 2011 at 5:50
2

Squid is not a good load balancer. It just doesn't have the necessary functionality. Use (or persuade the decision makers) HAProxy.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.