Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ashwani77-77 opened this issue Oct 23, 2024 · 1 comment

Comments

@Ashwani77-77
Copy link

Ashwani77-77 commented Oct 23, 2024

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.

@Ashwani77-77
Copy link
Author

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?

@liliankasem liliankasem transferred this issue from Azure/azure-functions-host Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant