Newer grafana sends an options request that graphite responds to with a 400 response. This response did not include allowed origin headers because it is a failure case. Update this header and the allowed methods header to always be included even on 400 or other error responses. This should ideally address the CORS errors we see with updated grafana. An alternative is to update grafana to proxy the requests for us, but this is less flexible as other tools may not have built in proxies. The suggestion comes from this stackoverflow question and answer: https://stackoverflow.com/questions/20414669/nginx-add-headers-when-returning-400-codes Change-Id: Icf1179d35e420384da72af839ca329548226ee63
62 lines
1.6 KiB
Django/Jinja
62 lines
1.6 KiB
Django/Jinja
server {
|
|
listen 80 default_server;
|
|
listen [::]:80 default_server;
|
|
server_name _;
|
|
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
server_name {{ inventory_hostname }};
|
|
|
|
ssl_certificate /etc/letsencrypt-certs/{{ inventory_hostname }}/fullchain.cer;
|
|
ssl_certificate_key /etc/letsencrypt-certs/{{ inventory_hostname }}/{{ inventory_hostname }}.key;
|
|
root /opt/graphite/static;
|
|
index index.html;
|
|
|
|
location /nginx_status {
|
|
stub_status on;
|
|
access_log off;
|
|
allow 127.0.0.1;
|
|
deny all;
|
|
}
|
|
|
|
# No remote login
|
|
location /admin {
|
|
allow 127.0.0.1;
|
|
deny all;
|
|
}
|
|
location /account {
|
|
allow 127.0.0.1;
|
|
deny all;
|
|
}
|
|
|
|
location /media {
|
|
# django admin static files
|
|
alias /usr/local/lib/python3.6/dist-packages/django/contrib/admin/media/;
|
|
}
|
|
|
|
location /admin/auth/admin {
|
|
alias /usr/local/lib/python3.6/dist-packages/django/contrib/admin/static/admin;
|
|
}
|
|
|
|
location /admin/auth/user/admin {
|
|
alias /usr/local/lib/python3.6/dist-packages/django/contrib/admin/static/admin;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8080;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
|
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, X-Grafana-Device-Id' always;
|
|
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
|
}
|
|
|
|
}
|