我在 Nginx 中有以下反向代理。我正在尝试隐藏签名密钥。
location /documents {
set $delimeter "";
if ($is_args) {
set $delimeter "&";
}
set $args "$args${delimeter}sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D";
proxy_pass https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/;
proxy_ssl_name testtestsitweu.blob.core.windows.net;
proxy_ssl_server_name on;
}
但是当我尝试通过
http://localhost:4200/documents/file.pdf
访问它时,我收到以下错误:
<?xml version="1.0" encoding="utf-8"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.
RequestId:8f693c6f-c01e-0000-65c7-647dca000000
Time:2024-02-21T13:11:22.3869564Z</Message></Error>
通常我可以从
https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/file.pdf?sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D
访问该文件
我在这里做错了什么?
尝试使用此代码,
location /documents {
set $delimeter "";
if ($is_args) {
set $delimeter "%26";
}
set $args "$args${delimeter}sp=rl&st=2024-02-15T14:18:59Z&se=2025-02-15T22:18:59Z&spr=https&sv=2022-11-02&sr=c&sig=TxTaaaaaaaaaaaaaaaaaaaaaaaaaaNgU%3D";
proxy_pass https://testtestsitweu.blob.core.windows.net/publicfiles/MyFiles/;
proxy_ssl_name testtestsitweu.blob.core.windows.net;
proxy_ssl_server_name on;
}
这可能是因为 Nginx 处理 URL 编码的方式。在您的配置中,当您设置 $args 变量时,& 字符需要进行 URL 编码为 %26,以确保它被正确解释为查询字符串的一部分。否则,它可能会被解释为配置中的分隔符。