I'm trying to setup Grafana running on docker-compose behind nginx reverse proxy, it works ok, as long as I is set [auth.anonymous] to enabled=true.
But When I disable anonymous signin, and Try to signin with "Authorization" token in header, I get the error below when navigation to Grafana sub_path:
If you're seeing this Grafana has failed to load its application files
This could be caused by your reverse proxy settings.
If you host grafana under subpath make sure your grafana.ini root_path setting includes subpath
If you have a local dev build make sure you build frontend using: npm run dev, npm run watch, or npm run build
Sometimes restarting grafana-server can help
my ngnix.conf settings are:
server {
listen 80
charset utf-8
location /grafana-dashboard/ {
proxy_pass http://grafana:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
}
}
Grafana is running on grafana:3000 from docker-compose.
docker-compose.config.yaml content is:
version: '3.4'
services:
grafana:
container_name: grafana
depends_on:
- db
networks:
- static-network
ports:
- 3000:3000
restart: always
volumes:
- grafana_stor:/var/lib/grafana
environment:
- GF_AUTH_PROXY_ENABLED=true
- GF_SERVER_DOMAIN=10.0.0.3
- GF_SERVER_ROOT_URL=http://10.0.0.3/grafana-dashboard/
user: "472"
volumes:
grafana_stor: {}
networks:
static-network:
ipam:
config:
- subnet: 172.20.0.0/16
Before accessing 10.0.0.3/grafana-dashboard/ I generate API_KEY using Grafana HTTP_API /api/auth/keys and then pass the returned token on "Authorization: Bearer [token]" header on the client.
Just to clarify, grafana-dashboard aimed to be displayed on an iframe within my webapp, but since I need to pass Authorization header, I make a request to the /grafana-dashboard/ that is served by nginx and then place the 'blob' response on an iframe.
The whole idea is to have "single sign-in" to grafana and to my webapp. So users that just signed-in to the webapp won't need to login to grafana as well. But if grafana is used directly (not from an iframe), grafana login screen or nginx simple authentication will be required.