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

2020-06-29  本文已影响0人  风吹散了的回忆

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

上一篇 下一篇

猜你喜欢

热点阅读