Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell AWS application load balancer to not forward the path pattern?

Tags:

I have configured my AWS application load balancer to have the following rules:

  • /images/* forward to server A (https://servera.com)
  • /videos/* forward to server B (https://serverb.com)

And this is correctly forwarding to the respective servers. However, I don't want the load balancer to forward the request as https://servera.com/images & https://serverb.com/videos. I just want the respective servers to be hit without the path pattern as https://servera.com & https://serverb.com (without the path patterns in the request).

I don't want to modify my request parameters or change my server side code for this. Is there a way I can tell the application load balancer to not forward the path patterns?

like image 437
jobin Avatar asked Aug 24 '16 15:08

jobin


People also ask

How do I achieve path based routing on an application load balancer?

Test path-based routing To test this routing, copy the DNS name of your Application Load Balancer in a web browser and add the URL path /svcA or /svcB. When the Application Load Balancer listener receives the request, the listener forwards that request to the appropriate target group based on the path condition.

Does ELB support path based routing?

Overview. AWS offers 3 types of load balancers as part of Elastic Load Balancer (ELB) service one is called Classic Load Balancer, TCP load balancer and the latest is the Application load balancer (ALB). ALB offers some unique features over Classic ELB and one of the features is Path-based Routing.

Where does an application load balancer forward network requests to?

Application Load Balancer routes requests to one or more registered targets (e.g., EC2 instances) using the protocol and port number configured by an organization.

How does the AWS load balancer routes traffic?

A load balancer accepts incoming traffic from clients and routes requests to its registered targets (such as EC2 instances) in one or more Availability Zones. The load balancer also monitors the health of its registered targets and ensures that it routes traffic only to healthy targets.


1 Answers

Is there a way I can tell the application load balancer to not forward the path patterns?

No, there isn't. It's using the pattern to match the request, but it doesn't modify the request.

I don't want to modify my request parameters or change my server side code for this.

You'll have to change something.

You shouldn't have to change your actual code. If you really need this behavior, you should be able to accomplish it using the web server configuration -- an internal path rewrite before the request is handed off to the application by the web server should be a relatively trivial reconfigurarion in Nginx, Apache, HAProxy, or whatever is actually listening on the instances.

Also, it seems to me that you are making things difficult on yourself by wanting the server to respond to a path different than what is requested by the browser. Such a configuration will tend to make it more difficult to ensure correct test results and correct handling of relative and absolute paths, since the applications will have an inaccurate internal representation of what the browser is requesting or will need to request.

like image 67
Michael - sqlbot Avatar answered Oct 27 '22 01:10

Michael - sqlbot