【发布时间】:2018-10-28 20:19:33
【问题描述】:
我正在尝试在 Nginx 反向代理后面设置 Grafana,但每次尝试通过浏览器午餐时都会出现 {{alert.title}} 错误。
Grafana 在 Kubernetes 集群内的 docker 容器中运行,并打开了 30000 端口。Nginx 在具有公共 IP 的 VM 内运行。
我可以在 nginx VM 中使用 Grafana 成功 curl url。
我还没有为我的公共 IP 分配公共 DNS 名称,所以我在配置中使用公共 IP 而不是 DNS 名称(但我也尝试通过在 /etc/hosts 中添加正确的记录来使用 DNS 名称 -一样)
我阅读了这篇文章“http://docs.grafana.org/installation/behind_proxy/”并在我的 grafana.ini 中进行了一些更改:
domain = PUBLIC_IP
root_url = https://PUBLIC_IP/grafana
在 nginx.conf 中
server {
listen 443 ssl;
server_name PUBLIC_IP;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /grafana/ {
proxy_pass http://IP_WHERE_LIVES_GRAFANA:30000/;
}
}
Nginx 访问日志:
2018/05/18 11:31:54 [error] 10847#0: *468 open() "/usr/share/nginx/html/public/css/grafana.dark.min.af13213c.css" failed (2: No such file or directory), client: CLIENT_PUBLIC_IP, server: PUBLIC_IP, request: "GET /public/css/grafana.dark.min.af13213c.css HTTP/1.1", host: "PUBLIC_IP", referrer: "https://PUBLIC_IP/grafana/"
【问题讨论】:
-
您确定您的 grafana.ini 正在加载吗?这些条目是否正确嵌套在
[server]部分下?你能分享你从 Grafana 获得的 html 的<head>部分吗? -
非常感谢您的建议!我的 Grafana 部署中有 GF_SERVER_ROOT_URL 环境变量,这就是它没有使用配置中的 root_url 的原因。
标签: docker nginx reverse-proxy grafana nginx-reverse-proxy