nginx版本
[root@znhjkapp04 nginx]# nginx -v
nginx version: nginx/1.14.0
grafana版本
v5.0.3
nginx配置
#反向代理grafana
location /grafana {
root html;
index index.html index.htm;
add_header 'Access-Control-Allow-Origin' '*';
add_header Access-Control-Allow-Methods GET,POST,OPTIONS,DELETE;
add_header 'Access-Control-Allow-Headers' 'userId,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
proxy_pass http://9.1.8.234:3000;
rewrite ^/grafana/(.*) /$1 break;
proxy_set_header Host $host;
#server_name_in_redirect off;
#proxy_set_header Host $host:$server_port;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header REMOTE-HOST $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#返回如下达不到预期
{{alert.title}}
Docs
Support Plans
Community
Grafana v5.0.3 (commit: 91162f3)
还需要修改grafana配置
domain = localhost
root_url=%(protocol)s://%(domain)s:%(http_port)s/grafana
以后访问grafana只能用nginx那个代理来访问了
参考文档http://yo.zgserver.com/nginx-grafana.html