Hello, in this short post I gonna explain why enterprise level apps should use management port.
By default app uses only one port and exposes all information to clients via it. But what if we want some data to be private for clients? Let's say we want health check to be available for k8s but not for consumers of our API. How to do that? The answer is separation of concerns. You should use separate ports in your app for different purposes. It's secure and simple way to handle this.
Management port is a private port for service endpoints. It is often used for:
1) Health checks
3) Custom endpoints for testing
Management port is usually not exposed outside so
you can be sure that clients won't access your private metrics or health checks data.
Asp.net core provides set of environment variables for configuring ports.
ASPNETCORE_MANAGEMENTPORT is responsible for management port, so your typical config looks like this:
This config uses ports
5001 in Kestrel,
5001 is management port.
Management port is fast and convenient way to expose private service endpoints in your app. Do you have those in your app? Feel free to answer in comments