Ngnix配置Minio动态代理:访问桶列表报错解决方案:

                    

多台服务器间免密登录|免密拷贝

Cenos7 搭建Minio集群部署服务器(一)

Cenos7 搭建Minio集群Nginx统一访问入口|反向动态代理(二) 

Spring Boot 与Minio整合实现文件上传与下载(三) 

CentOS7的journalctl日志查看方法

MySQL8.xx一主两从复制安装与配置

Ngnix配置Minio动态代理:访问桶列表报错解决方案


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


nginx配置如下:

[root@www conf]# cat nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    #配置反向代理及负载均衡器
    upstream minio_pool  {
      #server minio地址:端口号 weight表示权值,权值越大,被分配的几率越大;
      server 192.168.1.100:33806 weight=2;
      server 192.168.1.101:33807 weight=1;
      server 192.168.1.102:33808 weight=2;
      server 192.168.1.103:33809 weight=1;
    }

    server {
        listen       8877;
        server_name  192.168.1.111;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        
        location = /favicon.ico {
           log_not_found off;
           access_log off;
        }
        #location / {
        #    root   /usr/local/nginx/html;
        #    index  index.html index.htm;
        #}

        # 设置代理服务器
        location / {
           proxy_pass  http://minio_pool;  # 转向minio_pool
           proxy_redirect     off;#是否跳转
           proxy_set_header   Host             $host; #请求要转发的host
           proxy_set_header   X-Real-IP        $remote_addr;#请求的远程地址    这些在浏览器的header都可看,不一一解释
           proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           proxy_max_temp_file_size 0;
           proxy_connect_timeout      90; #连接前面的服务器超时时间
           proxy_send_timeout         90;#请求转发数据报文的超时时间
           proxy_read_timeout         90;#读取超时时间
           proxy_buffer_size          4k; # 缓冲区的大小
           proxy_buffers              4 32k; #
           proxy_busy_buffers_size    64k; # #proxy_buffers缓冲区,网页平均在32k以下的
           proxy_temp_file_write_size 64k; ##高负荷下缓冲大小(proxy_buffers*2)

        }


        #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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
 


解决方案:   在上配置基础上添加如下黄色部分配置即可

 # 设置代理服务器
        location / {
           proxy_pass  http://minio_pool;  # 转向minio_pool
           proxy_set_header Host $http_host;
           proxy_set_header X-Real-IP $remote_addr;
           #proxy_set_header X-Forwarded-Proto $scheme;
           proxy_set_header X-Forwarded-Host $http_host;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           
           # 添加了websocket支持
           proxy_http_version  1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           proxy_headers_hash_max_size 51200;
           proxy_headers_hash_bucket_size 6400;
           # websocket配置完成

           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           proxy_max_temp_file_size 0;
           proxy_connect_timeout      90; #连接前面的服务器超时时间
           proxy_send_timeout         300;#请求转发数据报文的超时时间
           proxy_read_timeout         300;#读取超时时间
           proxy_buffer_size          40k; # 缓冲区的大小
           proxy_buffers              4 32k; #
           proxy_busy_buffers_size    64k; # #proxy_buffers缓冲区,网页平均在32k以下的
           proxy_temp_file_write_size 64k; ##高负荷下缓冲大小(proxy_buffers*2)
           #客户端缓存时间,这里设置为7天,根据自己的需要设置即可
       expires 7d;
       add_header XCDN-Cache "$upstream_cache_status";


        }
 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值