Issue: can't login when reverse proxy is activated

Hello,
I’m using grafana 4.5.2 (commit: ec2b0fe6b).

I have issue of login when I use Grafana behind a reverse proxy. On the login page, when I enter my credentials, the green pop-up login “logged in” appears but I’m being redirect to the login page anyway, without access to the dashboard.

On the log I have the following:

t=2017-10-25T11:48:30+0200 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/ status=302 remote_addr=10.54.7.124 time_ms=3 size=37 referer="https://external_url/grafana/login?redirect=%2F"

If I allow anonymous connection, I have access to the dashboard, but when I try to login using the credentias, I got the same behavior: pop-up logged in appear, but I’m not really connected.

On the opposite, if I remove the reverse_proxy configuration from the custom.ini file and connect to Grafana directly from the hosting server I can connect without issue.

My custom.ini configuration (when I use the reverse proxy):

# Protocol (http, https, socket)
protocol = https

# The ip address to bind to, empty will bind to all interfaces
http_addr = 

# The http port  to use
http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = external_url

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = false

# The full public facing url
root_url = https://external_url/grafana/

My reverse proxy configuration:

<Location /grafana>
Header edit Location ^http://(.*)$ https://$1
ProxyPass https://hosting_server_ip:3000
ProxyPassReverse https://hosting_server_ip:3000
/Location>

Did I miss something?

Thanks for your help.

1 Like

Is that Apache you are using as the reverse proxy? Not sure if this is a config problem or a cookie problem.

At first glance, your config for Grafana and apache look ok but there could be a small error somewhere. Here is another example:

Could something be removing/not forwarding cookies? If the session cookie is removed then you will have to login in again.