基于grafana反向代理配置

2020-05-03   波波说运维

概述

今天主要介绍一下如何将grafana地址配到abc.com域名的/grafana/的location下,也就是用户访问访问http://abc.com/grafana正常跳转到内网的grafana地址,类似MQ配置。

这里简单做个记录。


一、nginx配置

相关配置如下:

nginx配置没啥好讲的,主要是grafana配置需要注意下...


二、grafana配置

在grafana配置文件(/etc/grafana/grafana.ini)中修改,配置后重启grafana

#################################### Server ####################################
[server]
# Protocol (http, https, h2, socket)
protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port to use
#默认3000,所以上面nginx也代理3000端口,这部分也可以改成任意端口号
http_port = 3000

# The public facing domain name used to access grafana from a browser
#配置外部访问域名
domain = app.xxx.com

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = false

# 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 = https://app.xxx.com/grafana

内网主要是配置domain和root_url了。


三、验证

1、外网访问https://app.XX/grafana

2、内网访问http://IP:3000



觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~