grafana使用nginx反向代理之域名访问

nginx代理访问grafana分为两步:

  1. 配置nginx
vim /usr/local/nginx/conf/nginx.conf

修改如下:

server {
      listen 80;
      root /usr/share/nginx/www;
      index index.html index.htm;
      //加入
      location /PaaS/grafana/ {
         proxy_pass http://localhost:3000/;   #注意3000后面的斜杠“/”不要漏掉
         proxy_set_header Host $host;
       }
}

保存,重载nginx

cd  /usr/local/nginx/sbin
./nginx -s reload
  1. 配置grafana
vim /etc/grafana/grafana.ini

修改如下:

[server]
domain = http://eip.ht.com.cn
root_url = %(protocol)s://%(domain)s/PaaS/grafana/

保存,重启grafana

service grafana-server restart

访问:http://eip.ht.com.cn/PaaS/grafana/?orgId=1

注:如果nginx的配置中proxy_pass http://localhost:3000/;后面不加斜杠,就会出现下面的情况:

image.png

If you're seeing this Grafana has failed to load its application files

  1. This could be caused by your reverse proxy settings.

  2. If you host grafana under subpath make sure your grafana.ini root_url setting includes subpath

  3. If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build

  4. Sometimes restarting grafana-server can help

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。