1

Some context here:

An old Symfony app is used in multiple EC2 instances. Handles millions of requests each day without issues.

For dev purposes, the app was added to a container and that container is used locally by the developers without having to install all the requirements. The dockerized app uses the same nginx/supervisor/php-fpm configs that productive ec2 instances.

To make easier some dev processes, it was decided to create multiple dev environments using AWS Fargate, instead of EC2 instances.

The image is pushed to ECR and is deployed using FARGATE strategy to clusters.

The approach perhaps is too much, since we have 1 Cluster running 1 service only with 1 task. That Service uses an ELB -> Target group.

The application is working fine, but after some time (hours, or days), some requests are returned with different headers. The response is a JSON, but the content type is returned as HTML, other headers are dropped from the request like access-control-allow-headers, access-control-allow-credentials, access-control-allow-methods, triggering a CORS error in the client's browser.

The weird part is that if 1 page creates 10 requests to this service, 9 will work correctly, but 1 request will return 200 with different headers. That endpoint consistently will behave in the same way to any user until the task is restarted.

The response headers are returned by the Symfony app. I also tried to force those headers including those in nginx config by default for every response, and the result is the same.

  • The docker image exposes port 80 to the service.
  • The load balancer has the rule to forward HTTPS (443) traffic to port 80, so traffic can reach the container.
  • The load balancer has enabled the use of HTTP/2

The only notable difference besides EC2/Fargate implementations is the load balancer. The production load balancer is an old class load balancer with only HTTP/1 enabled and the new ones are Applications load balancers using HTTP/2.

This is driving me crazy. Has anyone experienced something like this?

Incorrect headers

Incorrect headers

Correct headers

Correct headers

2
  • Non-answer/me-too here -- I've run into this today w/ a similar setup, but w/ Laravel - otherwise the same: php-fpm, nginx, supervisor, in a container. I may have eliminated the ELB as the culprit by going to the ECS > cluster > server > the running task, and changed my local front-end to hit the task's IP:port directly, which would skip the ELB all together (right?) - and the headers are being changed there, so I think it's something on the ECS side; not with the ELB, unless somehow being in a target group modifies the task? Gonna try forcing a redeploy on the service and see. Commented Oct 2, 2023 at 21:09
  • Forcing a redeploy on the service in ECS did indeed magically fix the missing headers in the response from the task - and also when pointed at the load balancer. So; I think it's in ECS Commented Oct 2, 2023 at 21:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.