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目录前缀是同一个,所有请求都到了一个前缀中,所以分成多个前缀后可以解决问题。

相关推荐
KYGALYX33 分钟前
在Linux中备份msyql数据库和表的详细操作
linux·运维·数据库
lang201509281 小时前
Linux高效备份:tar与gzip完全指南
linux·运维·服务器
wanhengidc2 小时前
云手机的基本原理
运维·服务器·游戏·智能手机·云计算
篙芷2 小时前
两台服务器 NFS 共享目录实战
运维·服务器
Hard but lovely2 小时前
linux: centos 软件包管理 yum源
linux·运维·centos
2301_816073833 小时前
Chrony服务器
运维·服务器
学网络的APang3 小时前
Apache HTTP Server 2.4.65 详细安装教程(基于 CentOS 7)
运维·网络
非典型代码3 小时前
Jenkins发不出邮件
运维·servlet·jenkins
b***25113 小时前
储能电池组的生产流程|深圳比斯特自动化
运维·自动化
实心儿儿4 小时前
Linux系统 —— 基础命令1
linux·运维·服务器