Skip to content

Instantly share code, notes, and snippets.

@feroda
Created February 11, 2018 20:47
Show Gist options
  • Save feroda/c6b8f37e9389753453ebf7658f0590aa to your computer and use it in GitHub Desktop.
Save feroda/c6b8f37e9389753453ebf7658f0590aa to your computer and use it in GitHub Desktop.
Django reverse proxy for Grafana SSO
"""
## Install the Django reverse proxy package: `pip install django-revproxy`
## Enable auth.proxy authentication in Grafana like the following
```
[auth.proxy]
enabled = true
header_name = X-WEBAUTH-USER
header_property = username
auto_sign_up = true
ldap_sync_ttl = 60
whitelist = 127.0.0.1
```
The whitelist parameter can be set if Django and Grafana are in the same host.
After that add this line in the Django project `urls.py`:
```
url(r'^dashboard/(?P<path>.*)$', views.GraphanaProxyView.as_view(), name='graphana-dashboards')
```
"""
from revproxy.views import ProxyView
class GraphanaProxyView(ProxyView):
upstream = 'http://localhost:8891/dashboard/'
def get_proxy_request_headers(self, request):
headers = super(GraphanaProxyView, self).get_proxy_request_headers(request)
headers['X-WEBAUTH-USER'] = request.user.username
return headers
@rahulkumarprasad
Copy link

Screenshot from 2021-10-04 16-41-38

hi sir i have tried to authintacate grafana using django-revproxy but it gave the above error, can you please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment