Rewrite works, but then the wrong backend is used

This is my query:

wget -O- -nv http://10.231.0.88/erech/contactYehaa

And this is my config:

frontend api
    bind 10.231.0.88:80
    acl myacl url_beg -i /erech/contact
    http-request replace-path ^/erech/contact(.*) /rest/api/submit-job/contact\1 if myacl
    use_backend foo if myacl
    default_backend bar

backend foo
    server foo 10.231.0.88:8900 check

backend bar
    server bar 10.231.0.88:8901 check

The rewrite works, but i end up on the bar backend. I would expect the rewrite to work and ending up on the foo backend.

Any idea what the problem could be?

When the use_backend directive evaluates the URL it is /rest/api/submit-job/contactYehaa and therefor myacl is false.

Match the new path instead.

use_backend foo if { path_beg /rest/api/submit-job/contact }

Otherwise you have to store the original path in a txn variable and use that for a match.

1 Like