Iframing Grafana

hi

I’m trying to iframe grafana to an application I’m building.

The idea is that when iframed, Grafana will load with read only access.

But I can also access it directly (outside of iframe) to login as admin and make changes.

Now the issue is, I’m not sure what direction to take. I’m trying both API token and Proxy Auth.

One idea was to make two location blocks in nginx,
one which is used for embeding, the other for normal authentication.

The problem is Grafana redirects me to the root_url and doesn’t authenticate as expected.

    location /grafana/ {
            proxy_pass http://grafana.staged-by-discourse.com/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }

    location /embed/ {
    proxy_pass http://grafana.staged-by-discourse.com/grafana/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    #        proxy_set_header X-WEBAUTH-USER embed;
    rewrite ^/embed/(.*) /$1 break;
    proxy_set_header Authorization "Bearer [redacted]$

    }
root_url = http://localhost/grafana

[auth.proxy]
enabled = true
header_name = X-WEBAUTH-USER
header_property = username
auto_sign_up = true
whitelist = 192.168.1.1, 192.168.2.1, 127.0.0.1

Any ideas?

Thanks in advance

Grafana does not support being accessed by two urls as cookies etc will be wrong.

Hi,
i try to integrate with Angular App, but i am facing CORS issue in Chrome. Please let me know how to fix it?