DEV Community

Ingvar
Ingvar

Posted on

2 1

Why Do You Need Management Port in Your Dotnet Web App

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"
Enter fullscreen mode Exit fullscreen mode

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay