joaonrb
joaonrb

Reputation: 1021

Can access a specific machine behind a haproxy loadbalancer for health check

I have a website served by several machines behind a haproxy loadbalancer. Now it use sticky sessions based on cookies. I'm using a uptimerobot to check the machines health but I cannot configure it to use cookies and I don't want the loadbalancer to be the only open point to the internet.

Is there a way to configure the load balancer to access the machines by a url parameter?

Upvotes: 1

Views: 123

Answers (1)

Ianthe the Duke of Nukem
Ianthe the Duke of Nukem

Reputation: 1761

There is a way but it isn't advisable. In the config, create duplicate backend blocks and url_param-based ACLs to route requests to specific servers based on a URL parameter.

Example:

frontend fe
    bind x.x.x.x:80
    bind x.x.x.x:443 ssl crt.. blah
    ...
    default_backend www

    acl is_healthchk_s1 url_param(CHECK) -i s1
    acl is_healthchk_s2 url_param(CHECK) -i s2
    acl is_healthchk_sn url_param(CHECK) -i sn

    use_backend be_healthchk_s1 if is_healthchk_s1
    use_backend be_healthchk_s2 if is_healthchk_s2
    use_backend be_healthchk_sn if is_healthchk_sn

backend www
    server s1 x.x.x.x:8080 check
    server s2 x.x.x.x:8080 check
    server sn x.x.x.x:8080 check

backend be_healthchk_s1
    server s1 x.x.x.x:8080 check
backend be_healthchk_s2
    server s2 x.x.x.x:8080 check
backend be_healthchk_s3
    server s3 x.x.x.x:8080 check

So, your uptime robot can check these instead:

  • domain.com/?CHECK=s1
  • domain.com/?CHECK=s2
  • domain.com/?CHECK=sn

Upvotes: 1

Related Questions