{"action":"created","issue":{"url":"https://api.github.com/repos/grafana/grafana/issues/732","labels_url":"https://api.github.com/repos/grafana/grafana/issues/732/labels{/name}","comments_url":"https://api.github.com/repos/grafana/grafana/issues/732/comments","events_url":"https://api.github.com/repos/grafana/grafana/issues/732/events","html_url":"https://github.com/grafana/grafana/issues/732","id":41366800,"number":732,"title":"Problem with setting up grafana with opentsdb and nginx","user":{"login":"mmohite","id":1237761,"avatar_url":"https://avatars.githubusercontent.com/u/1237761?v=3","gravatar_id":"","url":"https://api.github.com/users/mmohite","html_url":"https://github.com/mmohite","followers_url":"https://api.github.com/users/mmohite/followers","following_url":"https://api.github.com/users/mmohite/following{/other_user}","gists_url":"https://api.github.com/users/mmohite/gists{/gist_id}","starred_url":"https://api.github.com/users/mmohite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmohite/subscriptions","organizations_url":"https://api.github.com/users/mmohite/orgs","repos_url":"https://api.github.com/users/mmohite/repos","events_url":"https://api.github.com/users/mmohite/events{/privacy}","received_events_url":"https://api.github.com/users/mmohite/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/grafana/grafana/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-08-28T08:36:22Z","updated_at":"2015-02-03T08:15:40Z","closed_at":"2014-08-29T06:51:25Z","body":"We are trying to set up nginx with opentsdb.\r\nWhen we load \"http://grafana_host:8080/grafana-1.7.0-rc1/#/dashboard/file/default.json\"\r\nwe get following error in the chrome network console - \r\n\"XMLHttpRequest cannot load http://grafana_host:4242/api/suggest?q=co&type=metrics. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'grafana_host:8080' is therefore not allowed access. (index):1\r\n\r\ngrafana and opentsdb are running on the same host- \"grafana_host:\"\r\nthe nginx conf is - \r\n```\r\nuser www-data;\r\nworker_processes 4;\r\npid /run/nginx.pid;\r\n\r\nevents {\r\n\tworker_connections 768;\r\n\t# multi_accept on;\r\n}\r\n\r\nhttp {\r\n\r\n\t##\r\n\t# Basic Settings\r\n\t##\r\n\r\n\tsendfile on;\r\n\ttcp_nopush on;\r\n\ttcp_nodelay on;\r\n\tkeepalive_timeout 65;\r\n\ttypes_hash_max_size 2048;\r\n\t# server_tokens off;\r\n\r\n\t# server_names_hash_bucket_size 64;\r\n\t# server_name_in_redirect off;\r\n\r\n\tinclude /etc/nginx/mime.types;\r\n\tdefault_type application/octet-stream;\r\n\r\n\t##\r\n\t# Logging Settings\r\n\t##\r\n\r\n\taccess_log /var/log/nginx/access.log;\r\n\terror_log /var/log/nginx/error.log;\r\n\r\n\t##\r\n\t# Gzip Settings\r\n\t##\r\n\r\n\tgzip on;\r\n\tgzip_disable \"msie6\";\r\n\r\n\t# gzip_vary on;\r\n\t# gzip_proxied any;\r\n\t# gzip_comp_level 6;\r\n\t# gzip_buffers 16 8k;\r\n\t# gzip_http_version 1.1;\r\n\t# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;\r\n\r\n\t##\r\n\t# nginx-naxsi config\r\n\t##\r\n\t# Uncomment it if you installed nginx-naxsi\r\n\t##\r\n\r\n\t#include /etc/nginx/naxsi_core.rules;\r\n\r\n\t##\r\n\t# nginx-passenger config\r\n\t##\r\n\t# Uncomment it if you installed nginx-passenger\r\n\t##\r\n\t\r\n\t#passenger_root /usr;\r\n\t#passenger_ruby /usr/bin/ruby;\r\n\r\n\t##\r\n\t# Virtual Host Configs\r\n\t##\r\n\r\n\tinclude /etc/nginx/conf.d/*.conf;\r\n\tinclude /etc/nginx/sites-enabled/*;\r\n upstream opentsdb {\r\n  server grafana_host:4242 fail_timeout=0;\r\n}\r\n\r\nserver {\r\n  listen *:4243;\r\n\r\n  location / {\r\n    # Regex to whitelist systems\r\n    if ($http_origin ~* (https?://([a-z0-9._-]*\\.)?grafana_host(:[0-9]+)?)) {\r\n      set $cors \"true\";\r\n    }\r\n\r\n    # OPTIONS indicates a CORS pre-flight request\r\n    if ($request_method = 'OPTIONS') {\r\n      set $cors \"${cors}-options\";\r\n    }\r\n\r\n    # If it's OPTIONS, then it's a CORS preflight request so respond immediately with no response body\r\n    if ($cors = \"true-options\") {\r\n      add_header 'Access-Control-Allow-Origin' \"$http_origin\";\r\n      add_header 'Access-Control-Allow-Credentials' 'true';\r\n      add_header 'Access-Control-Max-Age' 1728000;\r\n      add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';\r\n      add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since';\r\n      add_header 'Content-Length' 0;\r\n      add_header 'Content-Type' 'text/plain charset=UTF-8';\r\n      return 204;\r\n    }\r\n\r\n    # Proxy the request\r\n    proxy_set_header X-Host grafana_host;\r\n    proxy_set_header X-Forwarded-For $Proxy_add_x_forwarded_for;\r\n    proxy_set_header Authorization \"\";\r\n    proxy_pass http://opentsdb;\r\n    proxy_redirect default;\r\n    proxy_buffer_size 16k;\r\n    proxy_buffers 8 32k;\r\n    proxy_busy_buffers_size 64k;\r\n    proxy_temp_file_write_size 64k;\r\n    proxy_read_timeout 120;\r\n    # Strip any OpenTSDB-generated CORS headers that overlap with our own\r\n    proxy_hide_header 'Access-Control-Allow-Origin';\r\n    proxy_hide_header 'Access-Control-Allow-Credentials';\r\n    proxy_hide_header 'Access-Control-Allow-Headers';\r\n\r\n    # if it's a GET or POST, set the standard CORS responses header\r\n    if ($cors = \"true\") {\r\n      # Add our own CORS headers\r\n      add_header 'Access-Control-Allow-Origin' \"$http_origin\";\r\n      add_header 'Access-Control-Allow-Credentials' 'true';\r\n      add_header 'Access-Control-Allow-Headers' '*';\r\n    }\r\n  }\r\n}\r\n\r\n}\r\n\r\n\r\n\r\n#mail {\r\n#\t# See sample authentication script at:\r\n#\t# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript\r\n# \r\n#\t# auth_http localhost/auth.php;\r\n#\t# pop3_capabilities \"TOP\" \"USER\";\r\n#\t# imap_capabilities \"IMAP4rev1\" \"UIDPLUS\";\r\n# \r\n#\tserver {\r\n#\t\tlisten     localhost:110;\r\n#\t\tprotocol   pop3;\r\n#\t\tproxy      on;\r\n#\t}\r\n# \r\n#\tserver {\r\n#\t\tlisten     localhost:143;\r\n#\t\tprotocol   imap;\r\n#\t\tproxy      on;\r\n#\t}\r\n#}\r\n```"},"comment":{"url":"https://api.github.com/repos/grafana/grafana/issues/comments/72610635","html_url":"https://github.com/grafana/grafana/issues/732#issuecomment-72610635","issue_url":"https://api.github.com/repos/grafana/grafana/issues/732","id":72610635,"user":{"login":"shilpi230","id":4164738,"avatar_url":"https://avatars.githubusercontent.com/u/4164738?v=3","gravatar_id":"","url":"https://api.github.com/users/shilpi230","html_url":"https://github.com/shilpi230","followers_url":"https://api.github.com/users/shilpi230/followers","following_url":"https://api.github.com/users/shilpi230/following{/other_user}","gists_url":"https://api.github.com/users/shilpi230/gists{/gist_id}","starred_url":"https://api.github.com/users/shilpi230/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shilpi230/subscriptions","organizations_url":"https://api.github.com/users/shilpi230/orgs","repos_url":"https://api.github.com/users/shilpi230/repos","events_url":"https://api.github.com/users/shilpi230/events{/privacy}","received_events_url":"https://api.github.com/users/shilpi230/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T08:15:40Z","updated_at":"2015-02-03T08:15:40Z","body":"I configured it with nginx following the same blog. But still not working."}}