Score:1

Haproxy set Host Header per origin Server

ug flag
Jay

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

Score:0
ug flag
Jay

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

Score:0
cz flag

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.

Jay avatar
ug flag
Jay
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)
Michael Hampton avatar
cz flag
@Jay You will have to use different backends, and it sounds like you really should be doing that anyway.
Jay avatar
ug flag
Jay
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.
Michael Hampton avatar
cz flag
@Jay https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.