官方文档地址:
https://grafana.com/tutorials/run-grafana-behind-a-proxy/
一级路径的配置方式
只需要修改Nginx配置文件,主要是增加对WebSocket的支持及反向代理的配置
map $http_upgrade $connection_upgrade {default upgrade;'' close;}server {listen 80;location / {proxy_pass http://localhost:3000/;}location /api/live {proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";proxy_set_header Host $http_host;proxy_pass http://localhost:3000/;}}重新载入nginx配置文件
/usr/local/nginx/sbin/nginx -s reload
二级路径路径的配置方式
除了需要修改nginx配置文件外,还需要修改grafana配置文件
map $http_upgrade $connection_upgrade {default upgrade;'' close;}server {listen 80;location ^~ /grafana/ {proxy_pass http://localhost:3000/;}location ^~ /grafana/api/live {proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";proxy_set_header Host $http_host;proxy_pass http://localhost:3000/;}}重新载入nginx配置文件
/usr/local/nginx/sbin/nginx -s reload修改grafana.ini配置文件
【Nginx反向代理Grafana服务的配置步骤】vi /etc/grafana/grafana.iniroot_url = %(protocol)s://%(domain)s:%(http_port)s/grafanaserve_from_sub_path = true重启Grafana服务
systemctl restart grafana-server
推荐阅读
- Nginx转发K8S、kubesphere的Ingress的WebSocket 请求时的不同配置
- 使用socat反向Shell多台机器
- 基于frp实现将安卓手机变成代理服务器
- nginx反向代理后,刷新页面无法访问,404错误,解决方法
- Nginx 基础入门
- Nginx负载均衡+转发策略
- Nginx高可用HA
- FRP 内网穿透、反向代理
- 进行爬虫时为什么需要代理?
- Nginx vs. HAProxy
