Ingvar
Posted on February 4, 2021
Hello, in this short post I gonna explain why enterprise level apps should use management port.
What is 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
2) Metrics
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.
Configuring
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:
"ASPNETCORE_URLS": "http://*:5000/;http://*:5001/",
"ASPNETCORE_MANAGEMENTPORT": "5001"
This config uses ports 5000
and 5001
in Kestrel, 5001
is management port.
Conclusion
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
Posted on February 4, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.