7
votes

We have a load balancer on amazon which balance 4 servers. When sending specific HTTP request to the load balancer I get Http error code 400. But when I sends the same request to each one of the servers directly I get Http 200 OK. Other requests are working fine when using the balancer.

Any Ideas?

Thanks.

4
Welcome to Stackoverflow. In order to get good responses to questions please consider posting some sample code - cordialgerm
Can you paste here the HTTP headers? - Ofir Luzon

4 Answers

8
votes

Don't know if this will help you, but I've had a similar problem. I was using jMeter and when accessing my instance over AWS load balancer I would always get: HTTP/1.1 400 BAD_REQUEST. After lot of debugging I found out that I was sending an empty header (no name and no value) because I had an empty row in HTTP Header Manager in jMeter. So, I persume, AWS ELB does some headers checking, and returns HTTP 400, even tough I wasn't having any problems with going with the same request to my instances directly. I don't know if this will help you but you should double-check your headers for some stupid mistake like this one :D

5
votes

I had a similar problem to this, and it was caused by ALB not accepting HTTP methods that are in lower case.

GET http://myhost.com/foo -> HTTP 200
get http://myhost.com/foo -> HTTP 400
1
votes

In my case it was the headers issue.

ELB-HealthChecker was sending healthcheck request to my web server and nginx replied with 400.

The issue was that ELB-HealthChecker sends no headers with the request. Depending on the configuration of your webserver, this might return 400 error code.

To check if this is the case, replicate "no headers" request with curl:

curl -I -H 'User-Agent:'  -H 'Accept:' -H 'Host:' http://yourservice/health/

The solution is to configure nginx endpoint that will return 200 regardless of the presence of the request headers:

location = /health/ { return 200; }
0
votes

In my case my target group for Port 443 was using HTTP protocol instead of HTTPs and I was getting 'Client using HTTP to connect to HTTPS server'