Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带Grafana的反向代理(nginx)_Nginx_Grafana_Nginx Reverse Proxy - Fatal编程技术网

带Grafana的反向代理(nginx)

带Grafana的反向代理(nginx),nginx,grafana,nginx-reverse-proxy,Nginx,Grafana,Nginx Reverse Proxy,我已经按照Grafana()提供的说明进行了操作,但仍然没有成功。下面是我的nginx配置文件。问题是当我转到它时,它会将我重定向到返回404的位置。谢谢你的帮助 NGINX配置文件 server { listen 80; listen [::]:80; server_name localhost; location / { root /usr/share/nginx/html; index index.ht

我已经按照Grafana()提供的说明进行了操作,但仍然没有成功。下面是我的nginx配置文件。问题是当我转到它时,它会将我重定向到返回404的位置。谢谢你的帮助

NGINX配置文件

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/;
    }
}
#################################### Server ####################################
[server]
# Protocol (http, https, h2, socket)
;protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port  to use
;http_port = 3000

# The public facing domain name used to access grafana from a browser
;domain = example.com

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
;root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
;serve_from_sub_path = true

# Log web requests
;router_logging = false

# the path relative working path
;static_root_path = public

# enable gzip
;enable_gzip = false

# https certs  key file
;cert_file =
;cert_key =

# Unix socket path
;socket =
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/;
    }
}
#################################### Server ####################################
[server]
# Protocol (http, https, h2, socket)
;protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port  to use
;http_port = 3000

# The public facing domain name used to access grafana from a browser
;domain = example.com

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
;root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
;serve_from_sub_path = true

# Log web requests
;router_logging = false

# the path relative working path
;static_root_path = public

# enable gzip
;enable_gzip = false

# https certs  key file
;cert_file =
;cert_key =

# Unix socket path
;socket =
我认为您必须在代理通行证url中添加“grafana”:

# Grafana
location /grafana/ {
    proxy_pass   http://www.example.com:3000/grafana/;
}

如果grafana在子路径上运行反向代理,则需要在grafana配置文件中相应地更新
根url

见相关文件

这是用于从web浏览器访问Grafana的完整URL。这 如果使用Google或GitHub OAuth身份验证(用于 回调URL必须正确)

注意:如果在中有反向代理,此设置也很重要 Grafana的正面,通过一个子通道将其暴露。在这种情况下,添加 指向此URL设置结尾的子路径


在您的Grafana配置文件中,
root\u url
service\u from\u sub\u path
处于注释中,请尝试删除
并重新加载NGINX

问题似乎出在grafana方面。检查grafana的访问日志和输出“curl-vhttp://www.example.com:3000/”很抱歉,我试图找出如何访问“访问日志”,但找不到任何内容。在Portainer中,当我尝试访问grafana时,它会输出此信息
t=2020-10-11T19:50:38+0000 lvl=info msg=“请求已完成”logger=context userId=0 orgId=0 uname=method=GET path=/grafana/status=302 remote\u addr=172.17.0.1 time\u ms=0 size=29 referer=
您能够在端口3000上卷曲服务器吗?如果是这样,grafana正在运行,我们可以只关注nginx问题。要进行测试,请尝试运行:curl-sS这应该会返回一大块文本(通常会在浏览器中呈现登录屏幕)——用户2863294 11分钟前我已经尝试过了,没有任何更改。我已经更新了我的帖子,包括Nginx配置文件和Grafana配置文件。谢谢。我已经对Grafana配置文件做了这个更改(请参阅我更新的帖子,其中包括Grafana配置文件)。也许我在配置文件中遗漏了什么。。。