Grafana behind Apache, Basic Auth edition

Grafana has a ridiculously flexible user login and access control system. Totally overkill in nine of ten cases, since it ends up sitting behind a server anyway.

In the case you are stuck using Apache and simply want to put a password on your pretty graphs, why not just use HTTP basic auth?

For some reason, this doesn't work with LocationMatch. But you can use the following:

<Location "/stats">  
  AuthType Basic
  AuthName "Stats Login"
  AuthUserFile /etc/apache2/grafana_htpasswd
  Require valid-user
  ProxyPass http://localhost:5000
ProxyPassReverse /stats http://localhost:5000  

With grafana_htpasswd generated by sudo htpasswd -cB /etc/apache2/grafana_htpasswd yourname.

Then, make sure /etc/grafana/grafana.ini includes:

# The http port  to use
http_port = 5000

# The full public facing url
root_url = %(protocol)s://%(domain)s:%(http_port)s/stats/  



lest Grafana think you want it to do the basic auth itself.

Restart both the apache2 and grafana-server services and everything should work.