Improve side-by-side configuration of HTTP/1.1 and HTTP/2 endpoints
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
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.
ASP.NET Core supports simple configuration of endpoints using environment variables, such as ASPNETCORE_HTTP_PORTS, ASPNETCORE_HTTPS_PORTS, ASPNETCORE_URLS.
However, if an app needs to support HTTP/1.1 and HTTP/2 side-by-side and without TLS, then endpoints need to be manually configured:
* https://github.com/bradygaster/dotnet-cloud-native-build-2023/blob/06670816357cf816a88741daf7d73c6a4487122b/ContosoOnline/Products/appsettings.json#L10-L18
* https://github.com/bradygaster/dotnet-cloud-native-build-2023/blob/06670816357cf816a88741daf7d73c6a4487122b/docker-compose.yml#L72-L74
Configuring endpoints manually is a wall of complexity that devs hit once they have this requirement. We should make this simple scenario simple to configure.
Require two ports is common in cloud-native apps:
* Apps don't use TLS to communicate because they're inside a private network, and having TLS certs everywhere is annoying. Therefore they can't use TLS+ALPN for protocol negotiation.
* Apps need HTTP/2 for gRPC and HTTP/1.1 for apps that don't support prenegotiated HTTP/2. For example, k8s health checks and Prometheus metrics scraping.
### Describe the solution you'd like
A new environment variable for explicitly configuring HTTP/2 alongside by HTTP/1.1.
```
ASPNETCORE_HTTP_PORT=80
ASPNETCORE_HTTP2_PORT=81
```
`ASPNETCORE_HTTP2_PORT` port wouldn't use TLS. An alternative name is ASPNETCORE_H2C_PORT (HTTP/2 cleartext), but H2C isn't a commonly used term by devs.
We need to figure out how `ASPNETCORE_HTTP2_PORT` (and `ASPNETCORE_HTTP_PORT`) interacts with endpoint defaults.
If the endpoint default version is HTTP/1.1 then `ASPNETCORE_HTTP2_PORT` should stay HTTP/2. But what about TLS?
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.