Re: Sticking to a particular server for testing...

From: Willy Tarreau <w#1wt.eu>
Date: Thu, 3 Jul 2008 06:56:28 +0200


On Wed, Jul 02, 2008 at 03:33:19PM -0700, Michael Nguyen wrote:
> So I'm just wondering if I can pick your brains regarding how to do this:
>
> 1) We use haproxy (of course!)
> 2) We stick to particular web servers based on the source IP address
>
> However, sometimes we want to be able to jump on a particular web server
> and to test out behavior. With our old load balancer, we were able to
> do as follows:
>
> http://www.twentyten.org/web01
>
> This would have the load balancer stick us onto web01 and then at that
> point any http://www.twentyten.org/xxx URLs would stick to that web
> server. What is the best way to do this in haproxy?

Generally, people rely on a cookie and set a cookie on their browser (potentially through an admin page on the application itself) and from this cookie, haproxy selects the appropriate server. Example :

	cookie SRV
	server srv1 1.1.1.1:80 cookie 1
	server srv2 1.1.1.1:80 cookie 2
	server srv3 1.1.1.1:80 cookie 3

In your request, you must set "Cookie: SRV=1".

Also, a few days ago, I realized that we are missing one "use_server" statement which would be the backend equivalent of the "use_backend" statement in frontends. That way you would be able to use "/web01" and indicate in the backend that it has to go to server 1 :

	acl web01 url_path /web01
	acl web02 url_path /web02
	acl web03 url_path /web03

	use_server srv1 if web01
	use_server srv2 if web02
	use_server srv3 if web03

	server srv1 1.1.1.1:80
	server srv2 1.1.1.1:80
	server srv3 1.1.1.1:80

At least it's motivating to see that there are potential users of features which don't exist yet :-)

Regards,
Willy Received on 2008/07/03 06:56

This archive was generated by hypermail 2.2.0 : 2008/07/03 07:00 CEST