Docker部署MinIO服务并使用Nginx反向代理
2024-09-05
Docker部署
这里默认装好docker
拉取MinIO镜像
docker pull minio/minio
创建minio服务目录
mkdir -p /home/minio/data
mkdir -p /home/minio/conf
启动容器
docker run \
-p 9000:9000 \ #minio_server的端口
-p 9090:9090 \ #minio_console的端口
--name minio \ #容器名
-e "MINIO_ROOT_USER=xxxxx" \ #用户名
-e "MINIO_ROOT_PASSWORD=xxxxxx" \ #密码
-e MINIO_SERVER_URL="http://xxx.xxx.xxx" \ #minio服务的域名
-e MINIO_BROWSER_REDIRECT_URL="http://xxx.xxx.xxx/minio/ui" \ #xxxx的内容和上一行一样
-v /home/minio/data:/data \ #挂载数据目录
-v /home/minio/conf:/root/.minio \ #挂载日志目录
-d minio/minio server \
/data --console-address ":9090" -address ":9000" #设置端口
一行
docker run -p 9000:9000 -p 9090:9090 --name minio -e "MINIO_ROOT_USER=xxxxx" -e "MINIO_ROOT_PASSWORD=xxxxxx" -e MINIO_SERVER_URL="http://xxx.xxx.xxx" -e MINIO_BROWSER_REDIRECT_URL="http://xxx.xxx.xxx/minio/ui" -v /home/minio/data:/data -v /home/minio/conf:/root/.minio -d minio/minio server /data --console-address ":9090" -address ":9000"
docker ps -a
查看容器状态
Nginx反向代理
官方文档:https://min.io/docs/minio/linux/integrations/setup-nginx-proxy-with-minio.html
配置文件:
# minio服务
upstream minio_s3 {
# least_conn; 负载均衡策略
server 127.0.0.1:9000;
}
# minio控制台
upstream minio_console {
# least_conn;
server 127.0.0.1:9090;
}
server {
listen 80;
listen [::]:80;
server_name minio.juicew.com www.minio.juicew.com; #你的minio服务的外部访问地址
client_max_body_size 0;
# minio服务地址必须是根目录,否则无法使用
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;
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio_s3;
}
# minio控制台地址
location /minio/ui/ {
rewrite ^/minio/ui/(.*) /$1 break;
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;
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
chunked_transfer_encoding off;
proxy_pass http://minio_console;
}
}
重启nginx
nginx -s reload
访问上文配置的域名
输入设置的账号密码登录