On Wed, 13 Aug 2014 14:22:28 -0400
Dave Shevett <[email protected]> wrote:

> Hi everyone.  We have a set of load balanced back end appservers behind
> haproxy.  We're running pretty large amount of traffic and things have
> been running great for the last 2 years or so.
> 
> We'd like the ability to manually specify a back end server within a
> cluster (this has to do with running a command to flush out the cache on
> a specific server). 
> 
> Without manually altering the cookie in the browser to specify which
> back end server to use, can we do something like add a string onto the
> URL to specify which of the back end servers to use?
> 
> For the following config, we normally hit http://stg.redacted.com, and
> it sets the HASRVID cookie which it uses to specify the back end.  Can
> we do something like http://stg.redacted.com/?HASRVID=stg-2 to manually
> select the back end?
> 
> Here's the relevant sections of our config file:
> 
> defaults
>     balance roundrobin
> 
> frontend http_proxy
>     use_backend blahblah
> 
> backend blahblah
>     mode http
>     option httpchk GET /magicurl
>     cookie HASRVID insert indirect nocache
> 
>     server stg-1 stg-1.REDACTED.com:80 cookie stg-1 check inter 10000
> rise 2 fall 5
>     server stg-2 stg-2.REDACTED.com:80 cookie stg-2 check inter 10000
> rise 2 fall 5
>     server stg-3 stg-3.REDACTED.com:80 cookie stg-3 check inter 10000
> rise 2 fall 5


Hi,

You have many way to do this:

 - The first way is to force the cookie (with a cgi in an
   administration web server in the same domain) and use the directive
   "force-persist" (ACL). This directive permits to connect to the
   server even if it is administratively down.

 - The second way is to create one backend per server and use ACL. The
   acl check the "HASRVID" argument an   frontend http_proxy
      use_backend stg1 if { urlp(HASRVID) stg-1 }
      use_backend stg2 if { urlp(HASRVID) stg-2 }
      use_backend stg3 if { urlp(HASRVID) stg-3 }
d choose a backend if it is
   found. The configuration is like this (untested):

   frontend http_proxy
      use_backend stg1 if { urlp(HASRVID) stg-1 }
      use_backend stg2 if { urlp(HASRVID) stg-2 }
      use_backend stg3 if { urlp(HASRVID) stg-3 }
      default_backend blahblah
  
   backend stg1
      server stg-1 stg-1.REDACTED.com:80 cookie stg-1

   backend stg2
      server stg-2 stg-2.REDACTED.com:80 cookie stg-2

   backend stg3
      server stg-3 stg-3.REDACTED.com:80 cookie stg-3

   backend blahblah
      [...]

 - Other way is to force the cookie with haproxy using ACL. It is a
   mix between the two last way:

   backend blahblah
      acl admin src <your.ip>
      http-request redirect location / set-cookie HASRVID=stg-1 if { 
urlp(HASRVID) stg-1 } admin
      http-request redirect location / set-cookie HASRVID=stg-2 if { 
urlp(HASRVID) stg-2 } admin
      http-request redirect location / set-cookie HASRVID=stg-3 if { 
urlp(HASRVID) stg-3 } admin
      http-request redirect location / clear-cookie HASRVID if { urlp(HASRVID) 
clear } admin
      force-persist if admin

      [...]


Thierry


> Thanks!
> 
>     -d
> 

Reply via email to