grafana nginx反向代理配置(适用于9.x.x以上版本)

在生产环境配置nginx转发grafana后,存在一些异常情况,由于不熟悉nginx的配置,花费了不少时间尝试,在此记录:

直接放解决方法:

首先修改grafana配置中的root_url,添加/grafana/,重启grafana,然后参考2.1中的配置修改nginx.conf后重启nginx服务

问题过程记录:

1.浏览器打开提示重定向次数过多

1.1解决方法:

nginx.conf中添加重写:

rewrite ^/grafana/(.*) /$1 break;

大概为捕获/grafana/后的所有内容,替换以剔除"/grafana/"

2.登录界面,和添加数据源等页面提示"Origin not allowed"

2.1解决方法:

参考官网配置方式Run Grafana behind a reverse proxy | Grafana Labs

将$http_host替换为grafana配置中的domain,默认为localhost

参考配置
        location  /grafana {
            #root   html;
            #index  index.html index.htm;
            proxy_set_header   Host localhost;
            proxy_set_header Origin https://localhost;
            proxy_pass http://127.0.0.1:3000;
            rewrite ^/grafana/(.*) /$1 break;
        
        }
​
        location /api/live/ {
            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://127.0.0.1:3000;
        }

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值