Hello ינון גינדי,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Problem
I understand that you are facing issue with the WAF IP addresses appearing in your Azure App Service logs instead of the real client IPs.
Solution
What I can suggest resolving the issue are the followings:
- Ensure that your Application Gateway is configured correctly to forward the original client IP address to the backend (your App Service). By default, Application Gateway does preserve the client IP address in the
X-Forwarded-For
header. So, you can check the configuration in your Application Gateway settings. If needed, update the configuration to ensure that the client IP is correctly forwarded. - Consider implementing custom logging in your App Service to capture the original client IP address. You can use the
X-Forwarded-For
header value (if available) to extract the client IP and in your Node.js application, you can access theX-Forwarded-For
header usingreq.headers['x-forwarded-for']
. - Finally, instead of using a third-party WAF, consider using Azure Front Door or Azure Traffic Manager. These services can handle traffic routing and provide additional features like Web Application Firewall (WAF) and client IP preservation. Azure Front Door, in particular, allows you to configure custom headers, including the client IP, which can be useful for logging purposes.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam