-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Is your feature request related to a problem? Please describe
When exposing VictoriaMetrics behind a reverse proxy on a specific path, we can take advantage of -http.pathPrefix
-like flags which allow VictoriaMetrics http servers to handle requests on this specific prefix.
This is convenient when all VictoriaMetrics endpoints are exposed under the same path.
More complex pattern would fail, though. (e.g. to expose the vmui under /ui
but the query paths under /query
)
Describe the solution you'd like
An emerging practice came from some reverse proxy implementation (Traefik and YARP) which is to pass to the backend a X-Forwarded-Prefix
containing the prefix that led a request to be forwarded to a particular backend.
The backend would not see the prefix in the path of the incoming request because the reverse proxy would have stripped the prefix. Instead, the handlers should be aware of the X-Forwarded-Prefix
and adapt their responses' relative URLs (e.g. path to .js
and static assets) accordingly by prefixing their relative URLs with the content of X-Forwarded-Prefix
.
More than enabling more complex pattern like the one described before, the cognitive load for the user would be lighter because VictoriaMetrics exposed behind a reverse-proxy that implements the X-Forwarded-Prefix
semantic would work out-of-the-box without manually passing the -http.pathPrefix
flag.
Describe alternatives you've considered
No response
Additional information
This is my first issue in this repo but I would gladly try to implement it and submit a PR.
For example, by adding a -http.UseXForwardedPrefix
flag that would enable VictoriaMetrics to use the header, or a disable flag if we want this behaviour to be enabled by default.
As I said, the practice is emerging so I would understand if you didn't want this feature, if so, feel free to tell me and close the issue. I will join some references that I used to create this issue.
- Traefik stripPrefix middleware, read the prefixes option details: https://doc.traefik.io/traefik/middlewares/http/stripprefix/
- Yet Another Reverse Proxy transforms about Forwarded request: https://microsoft.github.io/reverse-proxy/articles/transforms.html#x-forwarded
- How it was implemented in Symfony: [HttpFoundation] add support for X_FORWARDED_PREFIX header symfony/symfony#37734