Store host from previous page

I have two frontends on HAProxy. A user will visit one page, hosted by a server load-balanced by the first front-end. When the user clicks on a link, the page gets directed to another page on a server, load-balanced by another front-end on the same HA-Proxy instance.

Is there any way the second frontend can know the ‘host’ ( of the page it came from? Can I store this somehow with a variable in HAP?

In theory, I am thinking to set a ‘proc’ variable, then unset it after I make it to the second step. Would this work? I am not sure the scope of this type of variable as I’ve not used it before.

It is possible to store information about the host of the previous page in HAProxy, but it will require a bit of customization. Use a custom HTTP header to store the host of the previous page. For example, you could add a header called X-Previous-Host that contains the host of the previous page.

1 Like