Traefik 2.0: conditionally add headers (for authentication at Grafana)

462 Views Asked by At

I'm currently using the jwilder-nginx-reverse-proxy but planning to replace it with Traefik v2.0. Migrating all the configs of my docker instance worked fine so far but ATM I'm struggling with some piece of custom nginx configuration...

To have everyone on my local network (10.41.x.y) auto-login as admin at Grafana I added this hack to the nginx-config:

set $grafana_user "";
if ($remote_addr ~ "^10.41.") {
    set $grafana_user "admin";
}
proxy_set_header X-WEBAUTH-USER $grafana_user;

(Grafana is configured accordingly)

...everyone from the public internet will have to know the credentials.

This works great with the jwilder-nginx-reverse-proxy, but I can't figure out how to conditionally set headers in Traefik 2.0. So...

  1. ...in case I missed it: is there any way to conditionally set headers in Traefik?
  2. ...is there any other good way to accomplish this with Grafana? (on Grafana config I'm kind-of flexible)

Thanks a lot in advance!

0

There are 0 best solutions below