Looking to have some of the http incoming redirected to a specific backend based on path content and method type.
If path contains “string1” and is a POST → backend2
If path contains “string1” and is a PUT → backend2
If path contains “string1” and is a DELETE → backend2
default is backend1
my attempt (not working) from my cfg file:
use_backend backend2 if { path_sub /string1/ } { method POST }
use_backend backend2 if { path_sub /string1/ } { method PUT }
use_backend backend2 if { path_sub /string1/ } { method DELETE }
This was based on another use_backend instance that is working:
oh man thanks a TON for this example… I was just setting up a bunch of http servers to test my config
I’m going to simplify my cfg for now and vet it piece by piece…
thanks
EDIT: it looks like the version of HAProxy I am using is 1.8.27 while the latest version is 2.6… not sure if that may explain my issue. but I got errors when trying to add these backends…
Thanks a ton! these two test methods have already saved me hours.
I may have found my issue, and it’s annoyingly simple… specifying path_sub /string1/ instead of path_sub /string1 it wasn’t redirecting queries missing the trailing slash (oops).
Will implement these changes in the original setup and hopefully I’m good here.
Also planning on looking into the latest stable release for upgrade…