-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional port restriction for /metrics endpoint #1
Add optional port restriction for /metrics endpoint #1
Conversation
I need to find a better mechanism for determining the port. This implementation apparently takes it from
|
The real port is exposed by |
It is middleware. Use for all urls. If you want to change use only one url and port, you need use special endpoint: |
Well that was harsh. The middleware registration method already makes the basic setup simple. And this would be another step in that direction. The pattern of exposing the main functionality and maintenance functionality on different ports is used often in docker images and this would make it easy to do, without adding any overhead. |
I will think about this functional. But, I think we need use 'MapWhen'. Just return 'NotFound' is not Production ready |
I am already doing it with |
@nohwnd I would like to review and test it. |
Sure. I will update the PR tomorrow. |
Ok, I'm waiting update |
5311898
to
e6ac027
Compare
e6ac027
to
df6fd87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! I will test and publish it.
I would like to restrict metrics to be only accessible inside of Kubernetes cluster and not outside. One way to do this is to setup authentication and authorization for the metrics endpoint, but that adds unnecessary management overhead.
A simpler way to do this is to expose the metrics only on port that is reachable within the cluster and not outside. This PR adds such filter by checking the port in the incoming request and returning 404 if it does not match.
An example usage in the default ASP.NET Core 2.2 app with https redirection:
To test this with the standard app you can run those queries. (e.g. via VSCode rest client)