nginx反向代理到aws S3 ,解决S3返回500、502、503错误

nginx配置如下:

复制代码
        location ~ .*\.(js|css|woff|woff2|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma|svg|ico|xml|json|map|xhtml|yaml|cur|eot|ttf|mp4|otf|ogg|webp)$ {
                rewrite ^/(.*) /桶名称/test/static/$1 break;
                error_page 500 502 503 504 400 403 404 = /404.html;
                proxy_http_version     1.1;
                proxy_set_header       Connection "";
                proxy_set_header       Authorization '';
                proxy_set_header       Host s3.us-east-1.amazonaws.com;
                proxy_hide_header      x-amz-id-2;
                proxy_hide_header      x-amz-request-id;
                proxy_hide_header      x-amz-meta-server-side-encryption;
                proxy_hide_header      x-amz-server-side-encryption;
                proxy_hide_header      Set-Cookie;
                proxy_ignore_headers   Set-Cookie;
                proxy_intercept_errors on;
                add_header             Cache-Control max-age=2592000;
                proxy_pass             https://s3.us-east-1.amazonaws.com;
        }
        location / {
                rewrite ^/$ /桶名称/test/html/index.html break;
                rewrite ^/(.*)$ /桶名称/test/html/$1 break;
                error_page 500 502 503 504 400 403 404 = /404.html;
                proxy_http_version     1.1;
                proxy_set_header       Connection "";
                proxy_set_header       Authorization '';
                proxy_set_header       Host s3.us-east-1.amazonaws.com;
                proxy_hide_header      x-amz-id-2;
                proxy_hide_header      x-amz-request-id;
                proxy_hide_header      x-amz-meta-server-side-encryption;
                proxy_hide_header      x-amz-server-side-encryption;
                proxy_hide_header      Set-Cookie;
                proxy_ignore_headers   Set-Cookie;
                proxy_intercept_errors on;
                proxy_pass             https://s3.us-east-1.amazonaws.com;
        }

解决来自 Amazon S3 的 HTTP 5xx 错误 | AWS re:Post

问题现象是upstream_status 返回500、502、503,查阅官网文档发现是因为S3目录前缀是同一个,所有请求都到了一个前缀中,所以分成多个前缀后可以解决问题。

相关推荐
闲云一鹤2 天前
nginx 快速入门教程 - 写给前端的你
前端·nginx·前端工程化
碳基沙盒2 天前
OpenClaw 多 Agent 配置实战指南
运维
蝎子莱莱爱打怪5 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
何中应5 天前
Nginx转发请求错误
前端·后端·nginx
DianSan_ERP5 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
呉師傅5 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
不是二师兄的八戒5 天前
Linux服务器挂载OSS存储的完整实践指南
linux·运维·服务器
芝士雪豹只抽瑞克五5 天前
Nginx 高性能Web服务器笔记
服务器·nginx
zhangfeng11335 天前
趋动云 如何ssh登录 服务区 项目server
运维·人工智能·ssh