grafana反向代理之nginx

由于网络环境问题,我这边需要两层反代理,一般只做第一层反代即可。

1、nginx配置(第一层反代)

location ^~ /grafana/ {
    proxy_pass http://192.169.22.29:3003/;
    access_log logs/grafana.log main;
    proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;

    proxy_set_header Upgrade           $http_upgrade;
    proxy_set_header Connection        "upgrade";
    proxy_set_header Host              $http_host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;
  }
   

2、nginx配置(第二层反代)

  location ^~ /grafana/ {
    proxy_pass http://10.255.30.102:18088/grafana/;
    access_log logs/prometheus.log main;
    proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;

    proxy_set_header Upgrade           $http_upgrade;
    proxy_set_header Connection        "upgrade";
    proxy_set_header Host              $http_host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;
  }

3、修改grafana配置文件

vim /etc/grafana/grafana.ini
#添加以下代码 (结尾的grafana可进行修改,修改的同时 nginx配置文件内也要修改成一致)
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏
分享
评论 抢沙发