一、grafana修改配置
在root_url后边添加路径/grafana(该路径可自定义,和nginx配置中保持一致即可)
vim /etc/grafana/default.ini
# 后缀与nginx代理后缀保持一致
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
# 允许跨域
allowed_origins = *
# 允许iframe嵌入
allow_embedding = true
二、NGINX配置
# 代理Grafana
server{
listen 80;
server_name 10.0.52.222;
charset utf-8;
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://127.0.0.1:3000;
rewrite ^/grafana/(.*) /$1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
# websocket处理
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 处理grafana重定向问题, proxy_redict grafana默认路径 nginx代理路径
proxy_redirect http://localhost:3000 http://10.0.52.222:80;
}
}
标签:Control,http,header,grafana,NGINX,proxy,server
From: https://www.cnblogs.com/dbstack/p/18433880