1 下载minio
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
#启动minio,文件数据存放在/data目录
./minio server /data
2 部署minio
下载minio后赋予可执行权限就可以运行了,这里我整理了遇到的坑和解决问题的最终配置
在minio同目录下创建一个运行脚本run.sh,脚本写入如下内容
#!/bin/bash
export MINIO_ROOT_USER=minioadmin
export MINIO_ROOT_PASSWORD=密码
export MINIO_BROWSER_REDIRECT_URL=https://oss.example.com
export MINIO_SERVER_URL=https://ossapi.example.com
export CONSOLE_SECURE_TLS_REDIRECT="off"
/opt/minio/minio server /data --console-address ":9090" > /data/minio.log 2>&1 &
以后进入minio可执行目录./run.sh
就可以运行minio了,如果minio已经运行先kill掉
其中
export MINIO_BROWSER_REDIRECT_URL=https://oss.example.com
export MINIO_SERVER_URL=https://ossapi.example.com
export CONSOLE_SECURE_TLS_REDIRECT="off"
这个配置是解决minio在分享链接的时候是127.0.0.1这样的地址
我这里准备了两个域名,一个oss.example.com
对应的minio的网页管理地址,另一个ossapi.example.com
是minio的api访问地址
3 nginx配置
nginx这里有个坑就是配置好minio后websocket一直查询不到Bucket里面的文件,不是查询不到,是webscoket根本不通,报错内容如下,找了很多解决方案
WebSocket connection to 'wss://oss.example.com/ws/objectManager' failed: Error during WebSocket handshake: Unexpected response code: 400
Error in websocket connection. Attempting reconnection...
这块配置好之后就是分享链接一直是127.0.0.1的这种ip地址,这块按照第二步的配置MINIO_BROWSER_REDIRECT_URL
和MINIO_SERVER_URL
,CONSOLE_SECURE_TLS_REDIRECT
发一下我的nginx配置
upstream minio_console {server 127.0.0.1:9090 max_fails=3 fail_timeout=5s;
}
upstream minio_api {server 127.0.0.1:9000 max_fails=3 fail_timeout=5s;
}server {listen 443 ssl;server_name oss.example.com;proxy_headers_hash_max_size 1024;proxy_headers_hash_bucket_size 128; ssl_certificate /opt/ssl/oss/server.crt;ssl_certificate_key /opt/ssl/oss/server.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 10m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;client_max_body_size 1G;client_header_timeout 1m;client_body_timeout 1m;proxy_connect_timeout 60s;proxy_read_timeout 1m;proxy_send_timeout 1m;location / {proxy_pass http://minio_console;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header Host $http_host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}
}server {listen 80;listen 443 ssl;server_name ossapi.example.com;proxy_headers_hash_max_size 1024;proxy_headers_hash_bucket_size 128; ssl_certificate /opt/ssl/oss/ossapi.crt;ssl_certificate_key /opt/ssl/oss/ossapi.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 10m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;client_max_body_size 1G;client_header_timeout 1m;client_body_timeout 1m;proxy_connect_timeout 60s;proxy_read_timeout 1m;proxy_send_timeout 1m;location / {proxy_pass http://minio_api;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header Host $http_host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}
}
参考资料
https://github.com/minio/minio
https://min.io/docs/minio/linux/integrations/setup-nginx-proxy-with-minio.html?utm_term=&utm_campaign=&utm_source=adwords&utm_medium=ppc&hsa_acc=8976569894&hsa_cam=20593618271&hsa_grp=&hsa_ad=&hsa_src=x&hsa_tgt=&hsa_kw=&hsa_mt=&hsa_net=adwords&hsa_ver=3&gad_source=1&gclid=EAIaIQobChMIopXG3-6ThQMVzqNmAh2mXAUXEAAYASAAEgIPZvD_BwE