I am using Nginx to serve both graphite and grafana (they are all running on the same server - not my desktop). I am able to access graphite via Nginx. However, grafana cannot
I think you need to enable CORS in nginx configuration for graphite.Take a look at : http://enable-cors.org/server_nginx.html . Here's the configuration I made using this link:
(In my case, grafana is exposed on port 8100
, and graphite on port 8090
; adapt accordingly (8100
-> 85
, 8090
-> 8080
) ).
upstream django {
# Distribute requests to servers based on client IP. This keeps load
# balancing fair but consistent per-client. In this instance we're
# only using one uWGSI worker anyway.
ip_hash;
server unix:/tmp/uwsgi.sock;
}
server {
listen yourServerIp:8090;
server_name yourServerName.com;
access_log /var/log/nginx/graphite_access.log;
error_log /var/log/nginx/graphite_error.log;
charset utf-8;
# Django admin media.
location /media/admin/ {
alias /usr/lib/python2.7/dist-packages/django/contrib/admin/media/;
}
# Static media.
location /content/ {
alias /opt/graphite/webapp/content/;
}
# Send all non-media requests to the Django server.
location / {
# CORS (for grafana)
if ($http_origin ~* "^http://yourServerName.com:8100$") {
set $cors "true";
}
if ($request_method = 'OPTIONS') {
set $cors "${cors}options";
}
if ($request_method = 'GET') {
set $cors "${cors}get";
}
if ($request_method = 'POST') {
set $cors "${cors}post";
}
if ($cors = "trueoptions") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($cors = "truepost") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($cors = "trueget") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
uwsgi_pass django;
include uwsgi_params;
}
}
Note that the interesting part for you is what's below # CORS
, the django stuff might be useless for you.
To ensure it's a CORS issue, you want to inspect HTTP headers sent by your browser; if there's a Origin
header, it means you have to use CORS.