question

jhueppauff avatar image
0 Votes"
jhueppauff asked MikeUrnun edited

Azure Functions and CDN - Preserve Origin Hostheader

Hey Folks,

I am trying to create an Azure Function behind CDN. This works like any other function project I had in the past, so no issue here.

When I try to get the Hostname/Domain over which the function was called I always get the function hostname (I expect as it is used as hostheader in the CDN endpoint).
Is there any way I can retrieve the origin hostname / custom domain over which the Azure CDN Endpoint was called?

I am using a C# function at the moment. I tried already to use things like :
req.Headers["x-original-host"]
req.Headers["host"]
etc.

Thanks for the help

azure-functionsazure-cdn
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MikeUrnun avatar image
0 Votes"
MikeUrnun answered MikeUrnun edited

Hello @jhueppauff - Sorry for the late reply. I'm not aware of any headers or any way for Functions to automatically know or maintain the origin hostname value given your scenario. I believe that Azure CDN has to send it explicitly, preferably via headers. With that said, I did come across the following blog post which seems to be achieving the same thing but leveraging DNS configurations to do so: PRESERVING ORIGINAL HOST WITH AZURE CDN AND APP SERVICES

I'll continue to dig in and update my answer with any new findings.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.