Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

amazon s3 - HTTP 400 on S3 static file

We've spotted (in our error tracking tool) some http 400 issues while fetching some static files.

Also, there are logs in our API gateway regarding that it redirected the request to S3 which responded 400.

It's not our CDN neither our API gateway.

Why would S3 respond 400 to a static file?

We couldn't find anything exactly about it anywhere so far, but some general resources about 400 were pointing to issues with some HTTP header:

question from:https://stackoverflow.com/questions/65922171/http-400-on-s3-static-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since we couldn't manually reproduce that accessing our system, we started trying to fetch the static files with some unexpected headers using Postman.

We finally could quickly reproduce the issue by sending huge Cookies.

Our hypothesis is that, probably, Amazon S3's static website has some configuration that blocks requests with some specific long headers/cookies.

Once we couldn't find a way to configure that on S3, we've added a plugin to our API Gateway that when it was a static file request, it would remove the cookie before redirecting it to S3 (it wasn't required).

After that change, we've monitored our error tracking tool, and the occurrences of http 400 on static website dropped to 0.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...