1

We are trying to set host header per origin server, we can set per back end, but we are using default names on Azure app services, and as such the service will only respond to its own hostname, for example

http-request set-header Host example1.azurewebsites.net # for origin server 1

http-request set-header Host example2.azurewebsites.net # for origin server 2

However, can't see any way to set this on the origin server itself

server svr_example1 xx.xx.xx.xx:443 id 10 weight 10 maxconn 25 cookie exa1 check ssl verify none

server svr_example2 xx.xx.xx.xx:443 id 10 weight 10 maxconn 25 cookie exa1 check ssl verify none

Something like

server svr_example1 xx.xx.xx.xx:443 id 10 weight 10 maxconn 25 cookie exa1 check ssl verify none http-request set-header Host example1.azurewebsites.net

server svr_example2 xx.xx.xx.xx:443 id 11 weight 10 maxconn 25 cookie exa1 check ssl verify none http-request set-header Host example2.azurewebsites.net

Using haproxy version 1.8.28

Jay
  • 11
  • 1

2 Answers2

0

They are separate directives and you must put them on separate lines, e.g.:

backend svr_example1
        server svr_example1 xx.xx.xx.xx:443 id 10 weight 10 maxconn 25 cookie exa1 check ssl verify none
        http-request set-header Host example1.azurewebsites.net

Note that you can only do this when HAProxy terminates TLS. You cannot do this if you are passing through TLS.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • This doesn't work as we need to origin servers each with a distinct hostname backend svr_example1 server svr_example1 xx.xx.xx.xx:443 id 10 weight 10 maxconn 25 cookie exa1 check ssl verify none http-request set-header Host example1.azurewebsites.net server svr_example2 xx.xx.xx.xx:443 id 10 weight 10 maxconn 25 cookie exa1 check ssl verify none http-request set-header Host example2.azurewebsites.net Sadly only the last hostname is used, which results in a 404 from the Azure webapp (Domain must match) – Jay Jul 17 '21 at 19:52
  • @Jay You will have to use different backends, and it sounds like you really should be doing that anyway. – Michael Hampton Jul 17 '21 at 20:13
  • We would if we could, but from the FE side they use the same domain name, its only due to the way azure app services is setup that we need to supply a different host header. – Jay Jul 18 '21 at 07:15
  • @Jay https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain – Michael Hampton Jul 18 '21 at 12:31
0

Just to update, ended up implementing @Michael H suggesting with a twist, using 2 backends each with their own origin server and header information and then in the Front End using nbsrv to decide if the BE is valid and make a decision from there.

    acl beExampleDead1 nbsrv(S_be_Example1) lt 1
    acl beExampleDead2 nbsrv(S_be_Example1) lt 1

And then use the acl as part of the rule to decide on back end

Jay

Jay
  • 11
  • 1