0

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.

shinzou
  • 5,850
  • 10
  • 60
  • 124
  • The redirect you show is telling the browser to make a new request to a different URL; it is the browser (following the HTTP standard) which is deciding to make that a GET request. – IMSoP Jan 20 '21 at 19:06
  • So how can I make it keep the original request type? @IMSoP – shinzou Jan 20 '21 at 19:09

4 Answers4

1

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

fardin
  • 1,399
  • 4
  • 16
  • 27
0

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

Dave
  • 3,073
  • 7
  • 20
  • 33
-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

Skywalker
  • 41
  • 6
-1

there's http request methode option check this screenshot

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

Kamèl Romdhani
  • 342
  • 1
  • 9