Grafana Nginx Auth Proxy

I have been going round this for months and months as I am newbie to almost everything programming and environment.

I have my php application which has a MySQL backend. I have a Nginx webserver for the application.

I setup Grafana and am trying to use Nginx as auth proxy.

When I register/login into my app, user should be able to go directly into grafana without any credentials screen. In other words, Grafana should use my apps MySQL based authentication instead of its own authentication. I even have setup grafana to use MySQL instead of Sqllite.

But everytime I login or register, when I try to go Grafana, it goes to the grafana Login screen. What am I doing wrong.

My Nginx Conf is:

location /grafana/
#proxy_set_header Host $host;
#proxy_set_header X-WEBAUTH-USER $username;
#rewrite ^/grafana/(.*) /$1 break;

My Grafana conf is:

enabled = true
header_name = X-WEBAUTH-USER
header_property = username
auto_sign_up = true

If I use the following option in nginx,

proxy_set_header X-WEBAUTH-USER $username;

Then nginx fails with a message saying unknown variable username.

Please help.

Yes, you need some auth setup in nginx in that case, like basic auth or some other nginx auth integration.

In NGINX there is no preset variable called username. You need to set that variable to something, either culled from the request or set internally.

This is a list of nginx preset variables

For anything else, you need to define it yourself, probably using lua, or passing the username to nginx in a query string (might be dangerous) or through some other means.

Awesome. That gives me a sense of direction. Let me try something.

hello, Were you completed this case? I also find the answer that use grafana auth proxy with nginx. I need your help. Can you help me?


Hi. Is there any result of this integration?

FWIW I have this in my nginx config…
server {
listen [::]:443 ssl;
listen 443 ssl;

    auth_basic "Grafana";
    include /usr/local/etc/nginx/basic-auth.conf;
    proxy_set_header X-WEBAUTH-USER $remote_user;

    location / {

And it works with the existing basic auth I use for other things.

The auth.proxy section of the grafana config looks like
enabled = true
header_name = X-WEBAUTH-USER
header_property = username
auto_sign_up = true

Hi darius121, jmeterdude11

Did this integration got completed sucessfully?

I have similar use case in Grafana. Your reply would help us in configuring SSO in Ngninx & Grafana.



Can i use Nginx Auth Prosy with Ifream and auto login to Grafana