【问题标题】:Grafana Proxy New Domain to old DOmainGrafana 代理新域到旧域
【发布时间】:2021-07-10 17:44:21
【问题描述】:

我目前正在运行一个 Grafana 服务器,它前面有一个 NGINX 服务器,以便从我的 grafana.olddomain.uk 启动服务器:

location / {
    proxy_pass         http://127.0.0.1:3000;
}

我想从我的新域 (https://my.newdomain/grafana) 代理到旧域,但遇到了配置问题:

location /grafana {
  max_ranges 0;
  rewrite ^/grafana/(.*)$  /$1  break;
  proxy_pass https://grafana.olddomain.uk/;
  proxy_ssl_server_name on;
  proxy_ssl_trusted_certificate /etc/nginx/conf.d/trusted_ca_cert.pem;
  proxy_set_header Host $host;
}

这会引发 Grafana 提供的错误清除:

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.ini 但这会破坏 grafana.olddomain.uk。

在我的新域位置中需要什么才能使其正常工作?

编辑:来自https://my.newdomain.uk/grafana 的 curl 响应(重定向后)

> GET /grafana HTTP/1.1
> Host: my.newdomain.uk
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Fri, 16 Apr 2021 17:39:13 GMT
< Content-Type: text/html
< Content-Length: 162
< Location: https://my.newdomain.uk/grafana/
< Connection: keep-alive
<
> GET /grafana/ HTTP/1.1
> Host: my.newdomain.uk
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Fri, 16 Apr 2021 17:39:13 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: no-cache
< Expires: -1
< Pragma: no-cache
< X-Frame-Options: deny
<

【问题讨论】:

    标签: nginx grafana nginx-reverse-proxy nginx-location grafana-api


    【解决方案1】:

    因此,经过多次尝试使子路径正常工作后,我不得不放弃并将其设置为 root。这需要将所有配置拆分到单独的站点中。

    location / {
      max_ranges 0;
      proxy_pass https://grafana.olddomain.uk/;
      proxy_ssl_server_name on;
      proxy_ssl_trusted_certificate /etc/nginx/conf.d/trusted_ca_cert.pem;
      proxy_set_header Host $host;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      相关资源
      最近更新 更多