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

Deepak Kumar 1 Reputation point
2022-05-11T13:55:53.06+00:00

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 App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,908 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 48,576 Reputation points
    2022-05-11T14:26:40.757+00:00

    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.

    0 comments No comments

  2. ajkuma 22,416 Reputation points Microsoft Employee
    2022-05-13T19:06:02.31+00:00

    @Deepak Kumar , 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’.

    0 comments No comments