我已按照Grafana(https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1)提供的说明进行操作,但仍然没有成功。以下是我的Nginx配置文件。问题是当我转到http://www.example.com/grafana时,它会将我重定向到返回404的www.example.com/login。谢谢您的帮助!
NGINX配置文件
ROWNUM
Grafana配置文件
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# Portainer
location /portainer/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://www.example.com:9000/;
}
location /portainer/ws/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://www.example.com:9000/ws/;
}
# Grafana
location /grafana/ {
proxy_pass http://www.example.com:3000/;
}
}
答案 0 :(得分:0)
我认为您必须在proxy_pass网址中添加“ grafana”:
# Grafana
location /grafana/ {
proxy_pass http://www.example.com:3000/grafana/;
}
答案 1 :(得分:0)
如果grafana在子路径上运行反向代理,则需要相应地更新grafana配置文件中的root url
。
请参阅相关的documenttion
这是用于从Web浏览器访问Grafana的完整URL。这个 如果您使用Google或GitHub OAuth身份验证(对于 回调网址正确)。
注意:如果您在其中具有反向代理,则此设置也很重要 Grafana的前端,通过子路径将其公开。在这种情况下,请添加 该网址设置末尾的子路径。
答案 2 :(得分:0)
看起来在您的 Grafana 配置文件中,root_url
和 serve_from_sub_path
在注释中,只需尝试删除 ;
并重新加载 NGINX