Custom config in load balancer using selectors

I have set up a load balancer with the following docker-compose:

services:
  weblb:
    image: lb-service-haproxy:v0.7.15
    ports:
    - 80:80/tcp
    labels:
      io.rancher.container.agent.role: environmentAdmin,agent
      io.rancher.container.agent_service.drain_provider: 'true'
      io.rancher.container.create_agent: 'true'
      io.rancher.scheduler.global: 'true'

And rancher-compose:

services:
  weblb:
    start_on_create: true
    lb_config:
      certs: []
      config: |-
        global
          log 127.0.0.1:8514 local0 debug
        frontend 80
          option httplog
          log global
      port_rules:
      - backend_name: ''
        path: ''
        priority: 1
        protocol: http
        selector: proxy=me
        source_port: 80
        target_port: 80

I have multiple services using proxy=me selector in the following way (rancher-compose):

services:
  myservice:
    drain_timeout_ms: 5000
    scale: 1
    start_on_create: true
    lb_config:
      certs: []
      port_rules:
      - path: /myservice/
        target_port: 8080

Is there a way to add a custom “config” the services referenced by proxy=me selector only? I tried something like:

services:
  myservice:
    drain_timeout_ms: 5000
    scale: 1
    start_on_create: true
    lb_config:
      config: |-
        80_myservice_
            http-request replace-value X-Forwarded-For ^10\.42\.(.*)$ xxx.xxx.xxx.xxx
      certs: []
      port_rules:
      - path: /myservice/
        target_port: 8080

But unfortunately didn’t work.

Thanks in advance R.

1 Like