question

DeepakKumar-8706 avatar image
0 Votes"
DeepakKumar-8706 asked ajkuma-MSFT answered

Rename Server response header for Dotnet core webapp hosted on Azure with Linux operating system

We have hosted Dotnet core application on Azure using Linux operating system. While running our webURL we are getting server header as [Server Kestrel]. We want it to rename it to something else like test123.
Although we got solution to hide the server header info but not renaming.

Can anyone please help us to rename server header or share some link where it is mentioned that we cannot rename server header for webapp on Azure.

azure-webapps
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.

cooldadtx avatar image
0 Votes"
cooldadtx answered

If there is a customization exposed to do this I don't know what it is. But the headers are all available via the Response.Headers property in the controller. So all you really need to do is change the value at some point in the pipeline.

public IActionResult Index()
{
    Response.Headers["Server"] = "Mine";
    return View();
}


Of course you probably want to consider doing this in middleware or something instead of in every action.

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.

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered

@DeepakKumar-8706, Adding to cooldadtx on a similar lines -

On App Service when you perform any security testing, the result response is received from the frontends and never arrive to the actual worker (for example, invalid request).
Currently, if your requirement fits, you can App Gateway/WAF similar proxy in front and strip out the response header there. If it’s an enterprise app, it’s a good practice to have the WAF either way.

Please check this doc - Common scenarios for header rewrite

We have a UserVoice post on a similar request, ‘remove server header from the front end servers’ - you may wish to up-vote.

Also, up-vote ‘create custom error pages’ Uservoice post with a similar request.
Ref: similar discussion.


To benefit the community find the right answers, please do mark the post which was helpful by clicking on Accept Answer’ & ‘Up-Vote’.


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.