Skip to content

Load balancer is rejecting large posts

0

I need some urgent help. Yesterday I set up a load balancer and a second application server (EC2 instance). I tested them and then updated my app to use the load balancer address.

However, something's not working. When my app needs to upload a file (usually a picture from someone's phone) it doesn't work. I get a 403 response.

I can confirm that this does work if I upload it directly to one of the hosts without going through the load balancer.

I can't understand why this is happening. Is there some kind of a size limit or other restriction on the load balancer? If so, how do I disable it?

Thanks, Frank

asked a year ago1.6K views
3 Answers
1
Accepted Answer

The problem is AWS WAF, a service I was unaware of that was automatically enabled when I created my load balancer.

The solution was to go to the "WAF & Shield" console and disassociate the load balancer from WAF.

Amazon, please don't turn this on by default. I can't be the only developer who needs to send a large post body.

answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • Good that you got your issue resolved, but just to be sure, when I look at the ALB creation wizard, the WAF integration is shown as "optional" and not enabled by default, at least in my test account. There's a checkbox that is unchecked by default for me: "Include WAF security protections behind the load balancer". Another point I'd like to make is that while the default rules may block large requests, they can be allowed in a WAF ruleset (web ACL) too. Filtering large requests selectively is explained here: https://docs.aws.amazon.com/waf/latest/developerguide/waf-oversize-request-components.html

1

Hello.

If the ALB target is Lambda, there is a 1 MB limit, but I don't think there was any particular limit in the case of EC2.
https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html

It's just a guess, but is it possible that the web server running on EC2 is imposing a POST size limit?
When using Nginx etc., the default size limit is 1MB.
https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

EXPERT
answered a year ago
EXPERT
reviewed a year ago
  • Thanks for the response. The size of the post I'm trying to make is 436k. There is no size limit on the web server. I can upload the file directly to the server if I bypass the load balancer.

  • I see. By the way, are access logs and error logs output to the EC2 web server when files are uploaded via ALB?

0

I agree with Riku Kobayashi that there's no request body size limit on the ALB. It just passes the data through to the target. Are you perhaps using Web Application Firewall (WAF) on the ALB? It could be set to reject requests based on size, and often is configured that way, because WAF has limits to how much of the request it can inspect.

EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.