我试图从亚马逊 S3 存储桶提供静态和媒体文件,但 nginx 无法连接到它
这是我得到的错误
<Error>
<Code>AccessDenied</Code>
<Message>
AWS authentication requires a valid Date or x-amz-date header
</Message>
<RequestId></RequestId>
<HostId></HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)
和我的 Nginx 配置
server {
listen 80;
server_name my_elastic_ip;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
try_files $uri @s3;
}
location @s3 {
set $s3_bucket 'my_bucket.s3.amazonaws.com';
set $url_full '$1';
set $aws_access_key 'my_access_key';
set $aws_secret_key 'my_secret_key';
proxy_http_version 1.1;
proxy_set_header Host $s3_bucket;
proxy_set_header x-amz-date $date_gmt;
proxy_set_header Authorization 'AWS $aws_access_key:$aws_secret_key';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header Set-Cookie; …Run Code Online (Sandbox Code Playgroud)