使用MinioClient的getPresignedObjectUrl方法生成文件预签名的授权访问地址,直接使用MinioClient的endpoint域名或ip访问时正常,但是把endpoint的ip替换为经过nginx代理过的域名后,请求返回403。
原因:签名时的host与实际访问时的host不一致
解决方案:
修改nginx,minio代理部分,加入proxy_set_header ,确保与你代码里MinioClient的endpoint一致,这样minio收到的host就是原始host
bash
location / {
proxy_pass http://192.168.1.128:9000/;
index index.html index.htm;
# 原始的内部地址
proxy_set_header Host 192.168.1.128:9000;
# 其他必要的头部
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;
}