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:
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
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
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
there’s http
request methode option
check this screenshot
you can put there PUT or POST or GET like:
this
In case someone is using a client written in Golang, this is why redirected
POST
requests end up asGET
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