Search code examples
sslazure-web-app-serviceazure-cdn

Remote IP in Azure App Service served over HTTPS for a custom domain


My goal is to have an Azure App Service, served from a custom domain over HTTPS. This app receives HTTPS POST requests and should log the remote IP in the process.

I usually get the remote IP address, the IP of the calling client, like this:

HttpRequest request = ...
var IP = request.HttpContext.Connection.RemoteIpAddress;

To have the app served over HTTPS for a custom domain I enabled an azure CDN endpoint.

Now the IP I record is for the CDN server not the calling client.

Is it possible to get the originating IP?

The requests in question are HTTPS POST so CDN caching shouldn't be an issue.

Does the Azure CDN add any headers that could contain such info?

Does adding an SSL cert directly to the App Service change anything?


Solution

  • By testing I've found that Azure CDN adds the X-Forwarded-For header with the client's real IP.

    The only mention of this header I've found is in Azure CDN documentation mentioning the header as being reserved.