1. 程式人生 > >nginx反向代理grafana

nginx反向代理grafana

grafana安裝

https://grafana.com/grafana/download

Nginx設定如下:

    location /grafana {
        root   html;
        index  index.html index.htm;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS,DELETE;
        add_header 'Access-Control-Allow-Headers' 'userId,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        proxy_pass http://127.0.0.1:3000;
        rewrite ^/grafana/(.*) /$1 break;
        proxy_set_header   Host $host;
    #server_name_in_redirect off;
    #proxy_set_header Host $host:$server_port;
    #proxy_set_header X-Real-IP $remote_addr;
    #proxy_set_header REMOTE-HOST $remote_addr;
    #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

grafana配置檔案修改如下配置:

#在/etc/grafana/grafana.ini配置檔案中修改
domain = localhost
root_url = %(protocols)s://%(domain)s/grafana

訪問 ip/grafana 即可看到grafana介面。

參考:(配置都不全對,僅做參考)
https://blog.csdn.net/felix_yujing/article/details/72793863 (nginx配置不對,少了rewrite)
https://my.oschina.net/kcw/blog/2980304 (grafana的root_url不對)