我想在浏览器中使用pdfjs来显示s3中的pdf。https:/mozilla.github.iopdf.js。在使用s3 URL的地方,我已经反向代理了,就像这样
URL www.my-site-url.compublics3-presinged-url-bucket-part-with-sign-info
NGINX区块
location /public {
proxy_pass https://XXXX.s3.us-west-2.amazonaws.com/;
}
但S3会出现错误
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
如何正确地进行反向代理?
我在代理S3 URL的时候也遇到了类似的情况。在开发机器上一切正常,但在生产中却失败了,因为 CloudFront 添加了额外的头文件,改变了签名。在我的情况下,因为我已经有了有效的预签名 URL,但头文件没有被破坏,所以我添加了以下内容。proxy_pass_request_headers off;
以使代理请求与直接GET请求大致相当。