搭建MinIo

docker run \
  -itd \
  -p 9000:9000 \
  -p 9001:9001 \
  --name minio \
  -e "MINIO_ROOT_USER=账户" \
  -e "MINIO_ROOT_PASSWORD=密码" \
  -v /dcoker/minio/data:/data \
  quay.io/minio/minio server /data --console-address ":9001"

内部搭建的MinIo服务器映射到外网后访问文件资源一直报认证异常,经资料查阅minio有自己一套加密校验逻辑,访问时不可改动其桶名

解决内网穿透minio访问异常问题
通过nginx进行代理,代理时不改变访问路径,外网映射时映射nginx的代理地址

docker pull nginx
docker run --name nginx -d -p81:80 -itd nginx
mkdir -p  /usr/local/docker-soft/nginx/conf
mkdir -p  /usr/local/docker-soft/nginx/conf.d
docker cp nginx:/etc/nginx/nginx.conf /usr/local/docker-soft/nginx/conf/nginx.conf
docker cp nginx:/etc/nginx/conf.d/default.conf /usr/local/docker-soft/nginx/conf.d/default.conf
docker rm -f nginx

# 启动镜像并挂载
docker run  --name nginx -d -it \
-p 80:80 \
-v /usr/local/docker-soft/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /usr/local/docker-soft/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf \
nginx

修改Nginx配置

server {
        listen   80;

        # 这里对应桶名
        location /访问的桶名/ {
            proxy_read_timeout 600s;
            # 配置minio访问地址与桶名
            proxy_pass http://minio服务器IP:端口/访问的桶名/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Special-Delivery "";
            proxy_set_header Access-Control-Allow-Origin "";
            proxy_set_header Proxy-Client-IP $remote_addr;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            add_header X-Special-Delivery "stop-polling-our-interface-you-bitch" always;
            add_header Access-Control-Allow-Origin "you-poll-your-mama-blyat" always;
        }

    }
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐