grafana / helm-charts

Apache License 2.0
1.63k stars 2.26k forks source link

[grafana] Can't navigate to Login Page #1649

Open ghost opened 2 years ago

ghost commented 2 years ago

Hello,

we have a grafana v9.0.4 (c256012971) instance running inside a kubernetes cluster, which is proxied by a nginx instance. It is proxied behind a service inside the cluster. Not an ingress. Every redirect from nginx to grafana works fine except for one.

If i click on the login button, i would expect to navigate to this url: 'https://my.domain.com/k8s/clusters/xxx/api/v1/namespaces/monitoring-system/services/http:monitoring-grafana:80/proxy/login?forceLogin=true' But instead i get navigated to this one: 'https://my.domain.com/k8s/clusters/xxx/api/v1/namespaces/monitoring-system/services/http:monitoring-grafana:80/proxy/k8s/clusters/xxx/api/v1/namespaces/monitoring-system/services/http:monitoring-grafana:80/proxy/login?forceLogin=true'

The interesting part is, however, if i go manually to the first link i can login into grafana without problems.

I configured grafana and nginx according to the docs. My configuration files are below. Why is the sub url being repeated? What am i missing here or doing wrong?

Best Regards

ghost commented 2 years ago

grafana.ini

[analytics]
check_for_updates = true

[auth]
disable_login_form = false

[auth.anonymous]
enabled = true
org_role = Viewer

[auth.basic]
enabled = false

[grafana_net]
url = https://grafana.net

[log]
mode = console

[paths]
data = /var/lib/grafana/
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins
provisioning = /etc/grafana/provisioning

[security]
allow_embedding = true

[server]
domain = my.domain.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/k8s/clusters/xxx/api/v1/namespaces/monitoring-system/services/http:monitoring-grafana:80/proxy/
serve_from_sub_path = true

[users]
auto_assign_org_role = Viewer
ghost commented 2 years ago

nginx.conf

worker_processes auto;
error_log        /dev/stdout warn;
pid              /var/cache/nginx/nginx.pid;

events {
  worker_connections 1024;
}

http {
  map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
  }

  server {
    listen 8080;

    location / {
      rewrite ^/k8s/clusters/.*/proxy/(.*) /$1 break;
      proxy_set_header Host $http_host;
      proxy_pass http://localhost:3000/;
    }

    location /api/live/ {
      rewrite ^/k8s/clusters/.*/proxy/(.*) /$1 break;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_set_header Host $http_host;
      proxy_pass http://localhost:3000/;
    }
  }
}