I tried to setup grafana over nginx reverse proxy but I’m getting following error:
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_url setting includes subpath
- If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build
- Sometimes restarting grafana-server can help
also too many redirects in the network tab to login page.
I’ve followed the auth proxy setup doc but still I haven’t got it working.
What you expected to happen :
Grafana UI should work normally without any redirection issue.
How to reproduce it (as minimally and precisely as possible) :
here is my nginx.conf
`worker_processes 1;
events { worker_connections 1024; }
http {
log_format compression '$remote_addr - $remote_user [$time_local] ’
'"$request" $status $upstream_addr ’
‘"$http_referer" “$http_user_agent” “$gzip_ratio”’;
upstream docker-grafana {
server grafana:3000;
}
server {
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
listen 8081;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /grafana {
set $user "";
if ($args ~ "^user=(.+)") {
set $user $1;
}
add_header X-USER "$user";
add_header X-Forwarded-Host "$server_name";
add_header X-Forwarded-For "$proxy_add_x_forwarded_for";
add_header X-HOST "$host";
add_header X-REMOTE-ADDR "$remote_addr";
proxy_pass http://docker-grafana;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header X-WEBAUTH-USER $user;
proxy_set_header Authorization "";
}
}
}`
Here is my grafana.ini file:
`[server]
domain = 130.147.136.40:3000
root_url = http://130.147.136.40:3000/grafana/
[users]
allow_sign_up = false
auto_assign_org = true
auto_assign_org_role = Editor
[auth.proxy]
enabled = true
header_name = X-WEBAUTH-USER
header_property = username
auto_sign_up = false`
Here is my docker-compose file:
version: '2' services: reverseproxy: image: reverseproxy container_name: reverseproxy ports: - 8081:8081 restart: always prometheus: image: prom/prometheus container_name: prometheus volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml command: - '--config.file=/etc/prometheus/prometheus.yml' depends_on: - reverseproxy ports: - '9090:9090' restart: always pushgateway: image: prom/pushgateway container_name: pushgateway command: - '--persistence.file=pushgateway-metrics' - '--persistence.interval=10s' depends_on: - reverseproxy ports: - '9091:9091' restart: always grafana: image: grafana/grafana container_name: grafana volumes: - ./grafana.ini:/etc/grafana/grafana.ini environment: - GF_SECURITY_ADMIN_PASSWORD=admin - GF_AUTH_OAUTH_AUTO_LOGIN=true depends_on: - reverseproxy - prometheus ports: - "3000:3000" restart: always
whereas reverse-proxy is the container of Nginx.
Please, someone, help me fix this issue.