Re: URL Params

From: Holger Just <haproxy#meine-er.de>
Date: Mon, 06 Oct 2008 11:47:01 +0200


Brian Moschel wrote:
> Is it possible to point to a specific backend with url params the same
> way as cookies?
>
> I spent some time today reading over the docs thinking I'd set up URL
> params for sticky sessions, but it doesn't appear to be possible by
> default. From the url_param balance method:
>
> "If the parameter is found followed by an equal sign ('=') and a value,
> then the value is hashed and divided by the total weight of the running
> servers. The result designates which server will receive the request."
>
> This sounds like it uses a hashing algorithm but doesn't "stick" a
> specific value to a specific server in the same way that the cookies do.
> With cookies, I can set "cookie server1" in the server line, and when
> that is matched in the cookie, this is routed to server1. I need this
> to work exactly like cookies, where it looks for the url_param
> "server_dest=server1" and routes it to "server1". Is this possible?
>
> Thanks,
> Brian

Hi Brian!

You can solve this issue by using ACLs, which can match on various parts of the URL and headers. Please see section 2.3 of the configuration manual.

I have done it myself based on parts of the url but you can do it also like that:

defaults

	balance roundrobin
	mode http

frontend cluster :80
	acl static path_sub server_dest=static
	acl dynamic path_sub server_dest=dynamic

	use_backend static if static
	use_backend dynamic if dynamic
	default_backend dynamic

backend static
	server static_server 192.168.1.1:80 check

backend dynamic
	server dynamic_server 192.168.1.2:80 check


Regards, Holger Received on 2008/10/06 11:47

This archive was generated by hypermail 2.2.0 : 2008/10/06 12:00 CEST