Based on this scenario, what is the MOST cost-effective solution to this problem?
Remove the application from the ALB. Delete the ALB and change Amazon Route 53 to direct traffic to the instance running the application.
Remove the application from the ALB. Create a Classic Load Balancer in its place. Direct traffic to the application using the HTTP protocol.
Alter the application code to inspect the X-Forwarded-For header. Ensure that the code can work properly if a list of IP addresses is passed in the header.
Alter the application code to inspect a custom header. Alter the client code to pass the IP address in the custom header.
Explanations:
Removing the application from the ALB and directly routing traffic to the instance would bypass the ALB’s scaling and load-balancing features, reducing horizontal scalability. This also doesn’t solve the problem of preserving the client IP address.
Using a Classic Load Balancer doesn’t resolve the issue of capturing the client IP address in the application. It also doesn’t provide any additional benefits over the Application Load Balancer, which is more flexible and suitable for modern applications.
The ALB forwards the client IP address in the X-Forwarded-For header. Altering the application code to inspect this header allows the application to maintain the client IP address and scale horizontally. This is a cost-effective solution because it uses the existing ALB setup.
Using a custom header and altering the client code to pass the IP address would require additional complexity and effort in managing custom headers. The ALB already provides the X-Forwarded-For header, making this option unnecessary and more expensive.