美文网首页
grafana使用nginx反向代理之域名访问

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

作者: 风吹散了的回忆 | 来源:发表于2020-06-29 18:23 被阅读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

相关文章

网友评论

      本文标题:grafana使用nginx反向代理之域名访问

      本文链接:https://www.haomeiwen.com/subject/jprafktx.html