I've setup a Load Balancer in AWS which routes traffic to an Apache Ubuntu server.
When I browse to my URL, sometimes everything goes well. Then I hit the Refresh button and I start getting 502 errors when downloading some files. It's different files each time.
Then I hit Refresh again and everything goes fine.
I'm currently the only one using the server.
My Load balancer is setup like this:
- Availability Zones: us-east-1a and us-east-1b
- Security groups: port 80 and 443 opened
- Listeners: Port 80 redirect to port 443, port 443 forwards to my Target
My target group is configured like this:
- Target type: instance
- Protocol: HTTP: 80
- Load balancer: My load balancer name
- Register targets: I have 1 instance running in each zone.
My Auto Scaling Group is configured like this:
- Desired capasity: 2
- Minimum capacity: 2
- Maximum capacity: 5
- Availability zones: us-east-1a, us-east-1b
My apache server is configured with the default install values, plus:
- KeepAlive On
- Timeout 120
- KeepAliveTimeout 120
- MaxKeepAliveRequests 100
- AcceptFilter http none
- AcceptFilter https none
I'm not a server guy, I'm a programmer so I really don't know what to check. I thought configuring a Load Balancer was straight forward...
Thanks for your help
EDIT 2020-08-27 15h39
I enabled the logs on the VPC and on the Load Balancer and I refreshed my page. I had an 502 error on a specific file.
In the Load Balancer logs, I see the 502 entry for the specific file. Here`s the entry - JSON formatted - in which I replaced any sentive data
[
{
"type": "h2",
"time": "2020-08-27T19:20:52.547402Z",
"elb": "app/web-server-load-balancer/**my-load-balancer-id**",
"client:port": "*my-ip-address*:60831",
"target:port": "10.0.0.106:80",
"request_processing_time": 0,
"target_processing_time": 0.013,
"response_processing_time": -1,
"elb_status_code": 502,
"target_status_code": "-",
"received_bytes": 45,
"sent_bytes": 610,
"request": "GET https://**my-url** HTTP/2.0",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36",
"ssl_cipher": "ECDHE-RSA-AES128-GCM-SHA256",
"ssl_protocol": "TLSv1.2",
"target_group_arn": "**my-target-group-arn**",
"trace_id": "Root=1-5f480794-150df3bcad7fd0ac6bdfc41c",
"domain_name": "**my-domain-name**",
"chosen_cert_arn": "session-reused",
"matched_rule_priority": 0,
"request_creation_time": "2020-08-27T19:20:52.534000Z",
"actions_executed": "forward",
"redirect_url": "-",
"error_reason": "-",
"target:port_list": "10.0.0.106:80",
"target_status_code_list": "-",
"classification": "-",
"classification_reason": "-"
}
]
I don`t know if those data can help you helping me!
EDIT 2020-08-31 (1)
I opened the two VMs in the Firewall to access them directly. When I access each server directly, I do not get the 502 errors at all. When I access via the Load balancer, I get the 502.
EDIT 2020-08-31 (2)
I changed my load balancer to route the HTTP traffic to the instance instead of redirect it to the 443 port.
On port 80, I do not get 502 errors. I hard-refreshed many many times and did not get 502. As soon as access the load balancer with https, I start to get 502 errors. I remember you that when I directly access the VM with https, I do not get 502.