Force backend server with http header

Thanks a lot. The first part of my question is answered.
I’ve spent a lot of time searching the documentation, but I didn’t see this directive.

My second question can be answered with this line : http-response set-header X-Backend-Server %s

Here is a “full” example :

backend api.example.com
  balance            roundrobin

  use-server api1 if { req.hdr(x-backend-server) -i api1 }
  use-server api2 if { req.hdr(x-backend-server) -i api2 }

  http-response set-header X-Backend-Server %s

  server api1    127.0.0.1:8080 check
  server api2    127.0.0.1:8081 check

So if you set a request header X-Backend-Server that matches an existing server name, it will be used. and in any cas, the name of the used server is added to the response in the same header.

1 Like