dotnet / dotnet/aspnetcore

Server header value customization

Open
#48,798 6 comments 4 reactions 0 assignees View on GitHub
api-suggestion area-networking feature-kestrel
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I have reverse proxy (asp net core app with Yarp) that is deployed in front of my microservices. When examining the response that was send to that proxy I would like to be able to determine if this is the response from mentioned proxy or microservice itself. Previously we have been using Kong which customized server header value so it was clear who responded to request. After switching to new solution both domain microservice and reverse proxy are responding with server header equal to "Kestrel".

### Describe the solution you'd like

I would like to be able to customize server header value so it would be clear without any additional research who responded to incoming request. For example when request will be terminated by proxy due to fact that incoming request url doesn't match any of the yarp routes response header would look like this:
![image](https://github.com/dotnet/aspnetcore/assets/46067021/0a90f59c-6206-4db8-aa77-85dc37649731)

I imagine it something like this:
```
.UseKestrel(o =>
{
o.AddServerHeader = true;
o.ServerHeaderValue = "MyServiceName";
})
```

### Additional context

For now I believe I can achieve this with custom middleware but it would be great if this behavior would be achievable without such customization. It is important feature for my team since there are times during providing support for production incidents that we receive only screenshot from developer tools or xhr file and it would speed up determining logs of which component of our application we should examine (microservice and which one or reverse proxy).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.