Problem with reverse proxy after update to Grafana 10.0

I am running grafana inside docker with nginx reverse proxy.
After updating from 9.5.3 to 10.0 reverse proxy stopped working.
I am accessing grafana with mydomain.com/grafana/ but with version 10.0 it is no longer accessible and url in browser field gets changed to mydomain.com:3000/grafana

This is my grafana config:

domain = mydomain.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
serve_from_sub_path = true

This is my ngnix config:

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

upstream grafana {
  server grafana:3000;
}

server {
    listen      80;
    listen      [::]:80;
    server_name mydomain.com;
    root        /var/www/public;

    include     nginxconfig.io/security.conf;

    location / {
        return 301 https://mydomain.com$request_uri;
    }

    include nginxconfig.io/general.conf;
}

server {
    listen      80;
    listen      [::]:80;
    server_name *.mydomain.com;
    return      301 http://mydomain.com$request_uri;
}

server {
    listen      443 ssl http2 default_server;
    listen      [::]:443 ssl http2 default_server;
    server_name mydomain.com;
    root        /var/www/public;

    include snippets/signed.conf;
    include snippets/ssl-params.conf;

    include     nginxconfig.io/security.conf;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location ^~ /grafana {
        rewrite  ^/grafana/(.*)  /$1 break;
        add_header Content-Security-Policy "script-src: 'unsafe-eval' 'unsafe-inline';";
        proxy_set_header Host $http_host;
        proxy_pass http://grafana/;
    }

    location ^~ /grafana/api/live {
        rewrite  ^/grafana/(.*)  /$1 break;
        add_header Content-Security-Policy "script-src: 'unsafe-eval' 'unsafe-inline';";
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass http://grafana/;
    }

    include nginxconfig.io/general.conf;
}

Was there any configuration change thats need to be taken into acount to have working reverse proxy? Is there any solution to this problem?

1 Like

I had the same problem. I’ve changed serve_from_sub_path to false and then it started working again. You might want to give that a try.

3 Likes

It helped. Thanks a lot!