Can the Azure Load Balancer utilize the x-forwarded-for header

twilson 20 Reputation points
2024-09-23T16:49:03.85+00:00

Our solution has one or more proxies/ingresses that sit in front of a set of application VM's that we would like to load balance. This application requires session affinity (sticky sessions) and ideally we would like to use an Azure Load Balancer, however, it is unclear whether this LB can be configured to use the x-forwarded-for header as the source IP (the actual source IP in the requests are from the proxy). Some initial testing doesn't seem like it does, so trying to determine if there is a configuration somewhere to enable this?

Note that while the AppGateway might be a potential solution (cookie based affinity), ultimately we want to utilize an Azure scale set to automatically manage the number of these application VM's based on load and it is my understanding that scale sets utilize an Azure Load Balancer (and not an AppGateway).

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,457 questions
Azure Load Balancer
Azure Load Balancer
An Azure service that delivers high availability and network performance to applications.
443 questions
{count} votes

Accepted answer
  1. TP 95,556 Reputation points
    2024-09-23T20:08:05.6566667+00:00

    Hi,

    Azure Load Balancer can't use x-forwarded-for header. It is layer 4 balancer. Excerpt from documentation:

    Load balancer operates on layer 4 and doesn't provide application layer gateway functionality. Protocol handshakes always occur directly between the client and the backend pool instance.

    You can use Azure Application Gateway with VM scale set.

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.