Hello all! Long-time traefik user (mostly in Kubernetes!) branching out for more use cases.
Currently I'm trying to prototype a Traefik install that fronts, among other things, several Prometheus servers. These servers will end up on paths on the same hostname, such as <my-traefik>/prometheus/prometheus-dev-1
and <my-traefik>/prometheus/prometheus-prod-1
via the load balancer
I've been through a couple of iterations of configuration but have yet to find a workable solution. The issue is that when a user hits /
on a Prometheus server, it immediately 302's to /graph
and Traefik doesn't play nicely with 302s and path-based routing
I'm using file-based dynamic configuration, and I've tested two different configurations and have not gotten past the issue I'm running into.
The gist of the configuration I have right now is as follows:
---
entryPoints:
http:
address: ":80"
http:
routers:
prometheus:
middlewares:
- prometheus-path
rule: "Host(`twexler-k8s-cluster-workers.bdns.bloomberg.com`) && PathPrefix(`/prometheus/prometheus-dev-1`)"
service: "prometheus@file"
services:
prometheus:
loadBalancer:
healthCheck:
path: /graph
servers:
- url: "http://prometheus-dev-1:9090"
middlewares:
prometheus-path:
stripPrefix:
prefixes:
- "/prometheus/prometheus-dev-1"
This configuration results in an immediate redirect to <my-traefik>/graph
, since Prometheus is 302ing to /graph
and then eventually 404s.
If I change the prometheus-path
middleware to use ReplacePathRegex
, I get nearly the behavior I'm looking for, but resources requested by the Prometheus web UI still end up on /
(i.e. <my-traefik>/static/some-asset.js
)
prometheus-path:
replacePathRegex:
regex: "/prometheus/(.*)"
replacement: "/$1"
What's the correct way to get the behavior I'm looking for here? I've tried a bunch of iterations and can't find the right configuration that works.