尝试使用 nginx 服务器通过 graphite 设置 grafana 时,出现此错误:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
我尝试更改配置文件,但我的 grafana 配置文件仍然不起作用:
#Grafana Server Configuration
server {
listen 9400;
access_log /var/log/nginx/grafana.access.log;
error_log /var/log/nginx/grafana.error.log;
location / {
add_header Access-Control-Allow-Origin "ip address of the server";
add_header "Access-Control-Allow-Credentials" "true";
add_header "Access-Control-Allow-Methods" "GET, OPTIONS";
add_header "Access-Control-Allow-Headers" "Authorization, origin, accept";
root /usr/share/grafana;
}
}
答案1
您需要向Access-Control-Allow-Origin
标头添加完整的 URL,例如:
add_header Access-Control-Allow-Origin "http://example.com";