Azure/azure-functions-dotnet-worker

How to hide server details(Kestrel) in response headers for Function Hosted applications in .NET8

Ashwani77-77 opened this issue · 1 comments

I am working on .NET8 Azure Function in C# and I want to hide the Kestrel Server information from response headers.

We have migrated our application from (.NET6 in-process model to .NET8 isolated) and I have made a few changes in code to remove this server property from the response header.

I have added extensions property in host.json like this - -->

"extensions": {
  "http": {
    "customHeaders": {
      "Server": ""
    }
  }
}

and also I have added a configuration in Program.cs like this .--->

ConfigureWebHostDefaults(webBuilder =>
{
    webBuilder.UseKestrel(option => option.AddServerHeader = false);
})

It is working locally but when I am deploying it our function app is getting 500 Internal Server Error.
Also If we create a fresh new endpoint on .NET 8 isolated, then by default we don’t get any Server property in the response header.

I am looking for a solution to hide the server details from the response header of an Azure Functions endpoint. Please let know me know if there is any way?