我正在尝试将请求代理到数字海洋空间存储,例如:GET http://example.com/download/image_id.jpg
---> https://bucket-name.fra1.cdn.digitaloceanspaces.com/images/image_id.jpg
,但是我得到了
<Error>
<Code>NoSuchBucket</Code>
<BucketName>example.com</BucketName>
<RequestId>tx000000000000018d441fd-005d582ff2-1b7a15-fra1a</RequestId>
<HostId>1b7a15-fra1a-fra1</HostId>
</Error>
这是我的完整配置:
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /download/ {
proxy_pass https://bucket_name.fra1.digitaloceanspaces.com/images$request_uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
resolver 8.8.8.8;
}
}
我已经尝试了带有/不带有斜杠的不同选项,但是在仔细阅读文档之后,我认为现在是最佳的配置, 我也尝试调试要替换的地方
proxy_pass https://bucket_name.fra1.digitaloceanspaces.com/images$request_uri;
与
proxy_pass https://google.com/images$request_uri;
它给了我我所期望的。
根据文档,我想做的事情是这样的:
location /download/ {
proxy_pass https://bucket_name.fra1.digitaloceanspaces.com/images;
...
因此download
部分被images
取代了,但是那没用。
目前(在使用Google进行调试之后),我几乎有信心proxie_pass之后的网址等于https://bucket_name.fra1.digitaloceanspaces.com/images/image_id.jpg
,所以关键的问题可能是对“空间”的错误处理方式
P.S。我愿意接受有关记录/调试proxy_pass值的更好方法的建议。
答案 0 :(得分:0)
所以... proxy_set_header Host $host;
正在破坏一切。删除它固定修复。