How to copy X-Forwarded-For header to another header variable in AFD Standard rule set?

takeolexus 200 Reputation points
2025-07-31T00:40:11.2733333+00:00

Hello,

I am trying to add a rule set in AFD Standard to copy the X-Forwarded-For header to a different header variable.

The reason is that when configuring the Forwarded Headers Middleware in the backend ASP.NET Core, I need to dynamically obtain and set all of the AFD backend IP address using options.KnownProxies.Add(IPAddress.Parse("xxx.xxx.xxx.xxx")). To avoid this, I want to copy the X-Forwarded-For header to another header variable so that the Forwarded Headers Middleware does not interfere with retrieving the X-Forwarded-For header.

I defined the rule and associated it with the route as shown below, but the variable could not be retrieved.

Header Value is '{http_req_header_X-Forwarded-For}'.User's image

I referred to the following Learn article:

https://learn.microsoft.com/en-us/azure/frontdoor/rules-engine-scenarios?tabs=portal#scenario-2-populate-or-modify-a-response-header-based-on-a-request-header-value

Is it not possible to copy the X-Forwarded-For header to another header variable using this method?

Thank you in advance.

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
{count} votes

Accepted answer
  1. Praveen Bandaru 6,850 Reputation points Microsoft External Staff Moderator
    2025-07-31T15:36:21.6566667+00:00

    Hello takeolexus
    You're attempting to copy the X-Forwarded-For header to a different header variable in Azure Front Door (AFD) so your backend ASP.NET Core application can access it correctly without any issues.You should make sure that you're using the Rules Engine properly to modify the header as needed. According to the documentation on header actions in AFD, you can set up a rule to change the request headers.
    Here we need to add ruleset for the route that is matching incoming request custom domain and path users are accessing. You can set the new header to the value of X-Forwarded-For by using the header modification action type:

    • For example, assign the header value as {http_req_header_X-Forwarded-For}.

    Please ensure that the changes are deployed and properly linked to the route you are working on.

    If you’ve already configured this and it isn’t working, try the following checks:

    • Make sure the rule is enabled and properly linked to the AFD route.
    • Verify that no other rules or settings are conflicting and affecting header processing.

    Please check the below reference document:

    https://learn.microsoft.com/en-us/azure/frontdoor/front-door-http-headers-protocol


    Hope the above answer helps! Please let us know do you have any further queries.

    Please do not forget to “up-vote” wherever the information provided helps you, this can be beneficial to other community members. 


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.