skip to Main Content

I want to do something similar to this: Create AWS Application Load Balancer Rule which trim off request's prefix without using additional reverse proxy like nginx, httpd

Using AWS Load balancer, to redirect traffic from URL say /foo to /bar like this:

enter image description here

But only GET requests are routed correctly and POST,PUT,etc get routed as GET so I’m getting an error because my controller doesn’t have those GET methods.

Is there a way to do this with AWS load balancer?

The question I linked is from 2016 so I was hoping something has changed in 5 years.

4

Answers


  1. You can use /* in the IF section with a path as a condition.

    For example, IF /* THEN Redirect to.

    Additionally, you can use one of more condition in the IF section such as host-header, http-request-method, query-string, source-ip

    Login or Signup to reply.
  2. In the section in which you define the condition you have to specify the http method, otherwise it will consider GET as default.

    Example for the OPTIONS HTTP calls
    enter image description here

    Login or Signup to reply.
  3. there’s http request methode option
    check this screenshot

    you can put there PUT or POST or GET like:
    this

    Login or Signup to reply.
  4. In case someone is using a client written in Golang, this is why redirected POST requests end up as GET on the server side:

    https://github.com/golang/go/issues/18570
    https://cs.opensource.google/go/go/+/master:src/net/http/client.go;l=514

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search