# Customizing haproxy backends for a service loadbalancer

**URL:** <https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179>\
**Category:** Rancher 1.x\
**Created:** [April 18, 2017, 2:14pm UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179 "2017-04-18T14:14:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@quentin](https://forums.suse.com/u/quentin)\
**Post date:** [April 18, 2017, 2:14pm UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179/1 "2017-04-18T14:14:38Z")

</div>

Hi All,

I’m trying to create a redis HA cluster with Rancher, I’m almost done but I can’t understand how to customize my haproxy’s config with the rancher loadbalancer service.

I need to enable a public access with a custom haproxy backend.  
Here is my backend added inside “Custom haproxy.cfg” in the UI

backend redis\_master  
option tcp-check  
tcp-check connect  
tcp-check send PING\r\n  
tcp-check expect string +PONG  
tcp-check send info\ replication\r\n  
tcp-check expect string role:master  
tcp-check send QUIT\r\n  
tcp-check expect string +OK  
**server … IP:PORT _check inter 1s_**

==\> the bold text is generated automaticaly by rancher and I don’t know how to add the Italic text.

Any ideas ?

Here is my full rancher-compose.yml 🙂

```
version: '2'
services:
  redis-master:
    scale: 1
    start_on_create: true
  redis-lb:
    start_on_create: true
    lb_config:
      certs: []
      config: "backend redis_master\n\toption tcp-check\n\ttcp-check connect\n\ttcp-check\
        \ send PING\\r\\n\n\ttcp-check expect string +PONG\n\ttcp-check send info\\\
        \ replication\\r\\n\n\ttcp-check expect string role:master\n\ttcp-check send\
        \ QUIT\\r\\n\n\ttcp-check expect string +OK\n default-server inter\
        \ 1s\n\nbackend redis_slave\n option tcp-check\n default-server inter\
        \ 1s\n\nbackend stats\n mode http\n stats enable\n stats hide-version\n\
        \ stats show-node\n stats auth admin:password\n stats uri /haproxy-status"
      port_rules:
      - backend_name: redis_master
        priority: 3
        protocol: tcp
        service: redis-cluster
        source_port: 6377
        target_port: 6379
      - backend_name: redis_slave
        priority: 4
        protocol: tcp
        service: redis-cluster
        source_port: 6378
        target_port: 6379
    health_check:
      healthy_threshold: 2
      response_timeout: 2000
      port: 42
      unhealthy_threshold: 3
      interval: 2000
  redis-slaves:
    start_on_create: true
  redis-cluster:
    start_on_create: true
```

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 20, 2017, 8:48am UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179/2 "2017-04-20T08:48:48Z")

</div>

IIRC, you need to do something like this in your **docker-compose** file:

```auto
  redis-lb:
    ports: 6377:6377
    ports: 6378:6378
    ...

```

Or for a specific host IP:

```auto
  redis-lb:
    ports: 192.168.1.1:6377:6377
    ports: 192.168.1.1:6378:6378
    ...

```

---

<div class="post-metadata">

**Author:** ![quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@quentin](https://forums.suse.com/u/quentin)\
**Post date:** [April 25, 2017, 12:13pm UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179/3 "2017-04-25T12:13:55Z")

</div>

Thanks sjiveson unfortunately that’s not what I meant.

I need to change the haproxy conf generated with the servers IP.

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 25, 2017, 7:43pm UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179/4 "2017-04-25T19:43:51Z")

</div>

Sorry but I’m struggling to understand what it is you need?

---

<div class="post-metadata">

**Author:** ![rawmind](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/rawmind/32/3672_2.png) [@rawmind](https://forums.suse.com/u/rawmind)\
**Post date:** [April 26, 2017, 2:40pm UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179/5 "2017-04-26T14:40:43Z")

</div>

Hi @quentin

you could add parameters to your backend servers, adding that to your custom config

```auto
backend mystack_foo
    server $IP <server parameters>

```

[http://docs.rancher.com/rancher/v1.5/en/cattle/adding-load-balancers/#custom-configuration](http://docs.rancher.com/rancher/v1.5/en/cattle/adding-load-balancers/#custom-configuration)

In your case, it should be enough adding this custom configuration…

```auto
backend redis_master
option tcp-check
tcp-check connect
tcp-check send PING\r\n
tcp-check expect string +PONG
tcp-check send info\ replication\r\n
tcp-check expect string role:master
tcp-check send QUIT\r\n
tcp-check expect string +OK
server $IP check inter 1s

```

Could you try, please?? 🙂

---

<div class="post-metadata">

**Author:** ![quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@quentin](https://forums.suse.com/u/quentin)\
**Post date:** [April 26, 2017, 3:44pm UTC](https://forums.suse.com/t/customizing-haproxy-backends-for-a-service-loadbalancer/6179/6 "2017-04-26T15:44:28Z")

</div>

That’s exactly what I was looking for! Thanks a lot!!!
