在 Azure API 中使用应用程序网关方案管理保留客户端 IP 地址

Preserve Client IP address in Azure API Management with Application Gateway scenario

我在此设置中配置了 Azure Application GatewayAPI Management https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-integrate-internal-vnet-appgateway - 应用程序网关是 public 端点,只有定义的路由被传递到 API 管理。

我想使用 ip-filter 策略来限制对某些 IP 地址的调用。但是,当调用通过应用程序网关传入时,原始客户端 IP 地址丢失或混淆为 IP 0.0.0.0

有没有办法保留原始客户端 IP 地址并将其从应用程序网关传递到 API 管理?

您可能会发现这篇文章很有用:https://docs.microsoft.com/en-us/azure/application-gateway/how-application-gateway-works#modifications-to-the-request

An application gateway inserts four additional headers to all requests before it forwards the requests to the backend. These headers are x-forwarded-for, x-forwarded-proto, x-forwarded-port, and x-original-host. The format for x-forwarded-for header is a comma-separated list of IP:port.