Nginx – Error while setting up grafana with graphite and nginx

corselasticsearchgraphitenginx

While trying to setup grafana with graphite using nginx server. I am getting this error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
I tried changing configuration file but still not working my grafana configuration file:

#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;
  }
}

Best Answer

You need to add full URL to the Access-Control-Allow-Origin header, like:

add_header Access-Control-Allow-Origin "http://example.com";