简体   繁体   English

nganax反向代理背后的grafana

[英]grafana behind a nginx reverse proxy

I try to run grafana and nginx as reverse proxy in a kubernetes cluster and I already found this answer but this seems not to work for me. 我尝试在kubernetes集群中将grafana和nginx作为反向代理运行,我已经找到了这个答案,但这似乎对我不起作用。 At least I get the same {{alert.title}}-Message as Oles. 至少我得到与Oles相同的{{alert.title}}-消息。 That's why I would like ask again and maybe someone can give me a hint what I am doing wrong? 这就是为什么我想再问一遍,也许有人可以给我提示我在做什么错?

The configuration for the grafana deployment contains the following part: grafana部署的配置包含以下部分:

env:
  - name: GF_SERVER_DOMAIN
    value: "k8s-4"
  - name: GF_SERVER_ROOT_URL
    value: "http://k8s-4/grafana"

and I don't modify the grafana.ini inside the container/pod. 而且我不会在容器/吊舱内修改grafana.ini。

Further I configure the nginx in the default.conf as following: 进一步,我在default.conf中配置nginx如下:

server {
    listen       80;
    server_name  localhost k8s-4;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    location /grafana/ {
        proxy_pass http://k8s-4:30080/grafana;
        proxy_set_header X-Forwarded-Host k8s-4;
        proxy_set_header X-Forwarded-Server  k8s-4;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }

But as I say above this leads to the alert.title Error. 但是正如我上面所说,这会导致alert.title错误。 But if I set the context to the root Element and configured the tools as follows: 但是,如果我将上下文设置为根元素并按以下方式配置工具:

deployment: 部署:

env:
  - name: GF_SERVER_DOMAIN
    value: "k8s-4"
  - name: GF_SERVER_ROOT_URL
    value: "http://k8s-4"

nginx - default.conf nginx-default.conf

server {
    listen       80;
    server_name  localhost k8s-4;

    location / {
        proxy_pass http://k8s-4:30080/grafana;
        proxy_set_header X-Forwarded-Host k8s-4;
        proxy_set_header X-Forwarded-Server  k8s-4;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /grafana/ {
    }
}

it works... That's why I am quite sure this is a problem with the deployment of grafana but I don't see the error. 它可以工作...这就是为什么我非常确定这是grafana部署的问题,但我没有看到错误。 Maybe someone here can give me a little hint? 也许有人可以给我一点提示?

您的第一个server设置几乎是正确的,您需要将proxy_pass行更改为:

proxy_pass http://k8s-4:30080/;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM