Grafana采用Nginx反向代理

一、场景介绍

在常规操作中,一般情况下不会放开许多端口给外部访问,特别是直接 ip:port 的方式开放访问。但是 Grafana 的请求方式在默认情况下是没有任何规律可寻的。

为了满足业务需求(后续通过 Nginx 统一一个接口暴露 N 个服务),这里需要对 Grafana 做域名配置操作,可以参考本博客,同时也可以参考官方 的配置说明。

二、操作方式

  1. 修改 grafana.ini 配置信息如下
ini 复制代码
# The public facing domain name used to access grafana from a browser
domain = 192.169.5.208

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
serve_from_sub_path = true
  1. 重启 Grafana 容器
shell 复制代码
systemctl restart grafana-server
  1. 通过 Nginx 代理访问
nginx 复制代码
server {
		listen 80;
		......
		location /grafana {
			proxy_pass http://127.0.0.1:3000/grafana;
		}
}

三、常见问题

1.没修改root_url ,会有这个提示

直接访问 http://ip:port/grafana/,如果不配置会导致很多静态资源(js、css、html)都找不到路径,会有这个提示:

2.没修改serve_from_sub_path ,会有这个提示

直接访问 http://ip:port/grafana/


参考:https://blog.csdn.net/Rambo_Yang/article/details/108061345

相关推荐
AI精钢9 小时前
AI Agent 从上线到删库跑路始末
网络·人工智能·云原生·aigc
笨笨饿10 小时前
69_如何给自己手搓一个串口
linux·c语言·网络·单片机·嵌入式硬件·算法·个人开发
geneculture11 小时前
《智能通信速分多次传输技术(VDMT)》专利文件的全文汉英双语对照版本
服务器·网络·人工智能·融智学的重要应用·哲学与科学统一性·融智时代(杂志)·人机间性
MiNG MENS11 小时前
nginx 代理 redis
运维·redis·nginx
xrui5812 小时前
2026实战:深度解析 Gemini 3.1 镜像站函数调用在自动化运维工单中的应用
linux·服务器·网络
Python私教12 小时前
GenericAgent记忆系统深度解析:四层架构如何让AI拥有永不遗忘的大脑
网络·人工智能·架构
珊瑚怪人12 小时前
一个域名问题
nginx
雨辰AI13 小时前
SpringBoot3 + 人大金仓 V9 微服务监控实战|Prometheus+Grafana+SkyWalking 全链路监控
数据库·后端·微服务·grafana·prometheus·skywalking
时空系13 小时前
第9篇:成员功能——为结构体添加能力 Rust中文编程
开发语言·网络·rust
@encryption13 小时前
VLAN --- 深度学习
网络