Ldap lemon + nginx reverse proxy + grafana

I’m trying to configure ouath2 to grafana, my Oauth provider is Lemon Ldap but in front of my grafana I have nginx as proxy reverse and I think the Lemon ldap doesn’t know how to manage the nginx authentication, my config looks like :


server {
        listen 443 ssl default_server;
        server_name tool.domain.com;
        include snippets/self-signed.conf;
        include snippets/ssl-params.conf;
        client_max_body_size 500M;         
            location ~^/grafana {
                proxy_set_header Host $host;
                rewrite ^/grafana/(.*) /$1 break;



enabled = true
allow_sign_up = true
name = Orange Connect
client_id = grafana client
client_secret = sdffsdfs343lDS4ddfsd
scopes = openid profile email
auth_url = https://auth.tec.company/oauth2/authorize
token_url = https://auth.tec.company/oauth2/token
api_url = https://auth.tec.company/oauth2/userinfo

As a client, I’m accessing the grafana via nginx server "*https://tool.domain.com/grafana*" and if I want to connect on grafana via ouath2 it saying “Bad Url” or the bellow error:

2022/01/18 10:46:45 [error] 12408#0: *4798 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server: v, request: "GET /grafana/login/generic_oauth?code=4fc42bbae8e9e86f2a0cd62173feb3c8&state=eyQwXrY22iHNgBj4L2z6QY9mnt7ffwTjuapACY5tMsQ%3D&session_state=%2BaMXQ0Z3RUeElQQVRGTUNMNVVsTDRHNUdZMWg1dGtVd21SYkU4YXpKRDhhMXlmei94V2t5OUc HTTP/1.1", upstream: "", host: "tool.domain.com", referrer: "https://tool.domain.com/"

Should I configure on nginx server the client_id and client_secret from the Ldap lemon? I’m not an nginx server expert that’s why I’m looking a little bit help from your side.