使用nginx代理minio服务

问题遇到的现象和发生背景

查看存储桶的列表时候报错

img


报错信息 Objects List unavailable. Please review your WebSockets configuration and try again

操作环境、软件版本等信息

我的 Linux 服务器是 Centos07
我的 minio 版本是
minio -version
minio version RELEASE.2023-06-02T23-17-26Z (commit-id=0649aca2195a8d3aef9b946337b4ca6581e23844)
Runtime: go1.19.9 linux/amd64
License: GNU AGPLv3 https://www. gnu.org/licenses/agpl-3.0.html
版权所有:2015-2023 MinIO, Inc.

尝试过的解决方法

nginx的配置文件

  location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;

      proxy_connect_timeout 300;
      # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      chunked_transfer_encoding off;

      proxy_pass http://192.168.0.4:9000/; # This uses the upstream directive definitio
n to load balance
   }

   location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-NginX-Proxy true;

      # This is necessary to pass the correct IP to be hashed
      real_ip_header X-Real-IP;

      proxy_connect_timeout 300;

      # To support websocket
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";

      chunked_transfer_encoding off;

      proxy_pass http://192.168.0.4:9100/; # This uses the upstream directive definitio
n to load balance and assumes a static Console port of 9001
   }

我想要达到的结果

img

可以查看桶的列表信息

WebSockets的配置在好好检查下

答案参考Chatgpt Plus

检查权限:确保您具有适当的权限来访问存储桶和其中的对象。您可能需要检查您的访问密钥、IAM角色或存储桶策略,以确保您具有必要的权限。

检查WebSockets配置:如果您的应用程序使用了WebSockets,确保您的WebSockets配置正确。WebSockets是一种用于实现双向通信的协议,但在某些情况下,错误的配置可能会导致问题。请参考相关文档或咨询您的云服务提供商以获取正确的配置信息。

检查网络连接:确保您的网络连接正常工作,并且您可以访问存储桶所在的云服务。检查防火墙设置、网络代理或其他网络配置,确保它们不会阻止对存储桶的访问。

根据提供的信息,您在查看存储桶列表时遇到了报错信息 "Objects List unavailable. Please review your WebSockets configuration and try again"。这个错误可能是由于MinIO服务器的WebSockets配置问题导致的。

您提供的Nginx配置文件显示了代理设置,其中包括对WebSockets的支持。您可以检查以下几点来解决此问题:

  1. 确保您的Nginx版本支持WebSocket协议。在配置文件中,proxy_http_version 应设置为1.1,而且 UpgradeConnection 头信息应正确传递。
  2. 检查MinIO服务器的WebSockets配置。确保MinIO服务器的版本与您提供的信息相符。如果您的MinIO版本过旧,可以尝试升级到最新版本以解决潜在的问题。
  3. 验证您的防火墙设置。确保服务器上的防火墙允许通过所需的WebSockets端口进行通信。在MinIO的情况下,默认的WebSockets端口是9000或9001,取决于您的配置。
  4. 检查MinIO的日志文件以获取更多详细信息。MinIO的日志文件可能会提供有关连接错误或其他相关问题的线索。

通过仔细检查和调试这些方面,您应该能够解决报错信息 "Objects List unavailable. Please review your WebSockets configuration and try again",并能够成功查看存储桶列表。