Grafana配置匿名访问和nginx反向代理

2019-12-03  本文已影响0人  安悳坔

参考:

1. 修改grafana允许匿名查看

cat  /usr/share/grafana/conf/default.ini

[auth.anonymous]

# enable anonymous access
enabled = true         #默认false

# specify role for unauthenticated users
org_role = Viewer    #默认Viewer,可用Admin

2. 添加nginx反向代理

cat nginx.conf
        #反向代理grafana
        location /grafana {
            root   html;
            index  index.html index.htm;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS,DELETE;
            add_header 'Access-Control-Allow-Headers' 'userId,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            proxy_pass http://192.168.0.250:3000;
            rewrite ^/grafana/(.*) /$1 break;
            proxy_set_header   Host $host;
        }

3. 仅仅在nginx中配置还不够,还需修改grafana

cat  /usr/share/grafana/conf/default.ini
domain = www.youdomain.com
root_url=%(protocol)s://%(domain)s:%(http_port)s/grafana

注意:修改访问路径到/grafana之后,直接再用ip访问就会出现如下情况:

error.png
上一篇下一篇

猜你喜欢

热点阅读