报错信息: 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";
}