403 服务器无法验证请求。确保授权标头的值格式正确,包括签名

问题描述 投票:0回答:1

我被告知可以从 Azure 提供静态内容(.pdf 和 .docx 文档)。首先,我尝试从此“Blob SAS URL”链接获取我的 PDF 列表:

GET https://testtestsitweu.blob.core.windows.net/publicfiles?sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxAaaaaaaaaaaaaaaaaaaaaagU%3D

但是即使它具有“列表”和“读取”权限,它也会给我以下错误:

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>AuthenticationFailed</Code>
    <Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:b5d14821-701e-0083-2939-6363a8000000
Time:2024-02-19T13:42:06.9875994Z</Message>
    <AuthenticationErrorDetail>Signature did not match. String to sign used was rl
2024-02-15T14:18:59Z
2025-02-15T22:18:59Z
/blob/testtest/$root


https
2022-11-02
c






</AuthenticationErrorDetail>
</Error>

我在这里做错了什么?为什么它要求授权标头?那是什么?如果我想在公共网络中提供静态内容,为什么需要授权标头?我使用了错误的工具?

azure nginx static-site
1个回答
0
投票

我在这里做错了什么?

请参阅我对此的回答:https://stackoverflow.com/a/25038738/188096。简而言之,您需要将 blob 的名称放在要服务的容器名称后面。

为什么它要求授权标头?

对 Azure 存储的请求必须经过授权。当您进行直接 REST API 调用时,您可以在授权标头中传递授权信息。对于 SAS URL(如您正在使用的 URL),授权标头包含在 URL 本身中(URL 的

sig
部分)。

如果我想提供静态服务,为什么需要授权标头 公共网络上的内容?

我假设保存静态内容的 blob 容器具有

Private
ACL。这就是您需要授权标头的原因。您可以做的一件事是将 blob 容器的 ACL 更改为
Blob
Public
,然后就不需要授权(甚至是 SAS URL)。您的 blob 将可以通过类似
https://account.blob.core.windows.net/container/myfile.pdf
的 URL 直接访问。

© www.soinside.com 2019 - 2024. All rights reserved.