【发布时间】:2015-04-02 15:20:38
【问题描述】:
我正在尝试在 nginx 之上设置 Grafana。这是我当前的设置。 Grafana 应该在同一台服务器上与石墨和弹性搜索进行对话。
这是我的 nginx 配置文件。我不确定这个配置有什么问题:
#graphite server block
server {
listen 8080 ;
access_log /var/log/nginx/graphite.access.log;
error_log /var/log/nginx/graphite.error.log;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
}
#grafana server block
server {
listen 9400;
access_log /var/log/nginx/grafana.access.log;
error_log /var/log/nginx/grafana.error.log;
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
add_header Access-Control-Allow-Origin 'http://54.123.456.789:9400';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE';
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, origin, accept';
add_header 'Access-Control-Allow-Credentials' 'true';
root /usr/share/grafana;
}
}
现在,每当我尝试运行 Grafana 时,都会出现以下错误:
XMLHttpRequest cannot load http://54.123.456.789:8080/render. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://54.123.456.789:9400' is therefore not allowed access.
有人可以帮我解决这个问题吗?提前致谢。
【问题讨论】:
标签: angularjs nginx xmlhttprequest graphite grafana