0
votes

I want to have a haproxy in front of some iis servers.

My problem is that on the iis servers I have three applications.
app1.domain.com
app2.domain.com
app3.domain.com

On the frontend. I do not want to show the sub domains.

So I want do write:
www.domain.com/app1
www.domain.com/app2
www.domain.com/app3

And on the backend I want to change both the host and url to match each application.

I have an idea how to rewrite all this, but that will require to duplicate all real servers in multiple backed parts on the haproxy.

So my question is: Can I rewrite URL and Hosts before choosing a backend? Or can one backend do multiple rewrites based on some conditions?

1

1 Answers

0
votes

If they are different backends why wouldn't you want to create different rules for them? there's always something different to config for your backends even if the applications are quite similar. HAProxy is meant to be lightweight so if you're trying to write variables in your rewrites that is not going to work.

My config would look something like this:

acl domain hdr_dom(host) -i www.domain.com

acl app1 path_beg /app1
acl app2 path_beg /app2
acl app3 path_beg /app3

use_backend backend_app1 if app1 domain
use_backend backend_app2 if app2 domain
use_backend backend_app3 if app3 domain

backend backend_app1
    reqrep ^([^\ ]*)\ /app1before    \1\ /app1after
    server server_app1 app1.domain.com
backend backend_app2
    reqrep ^([^\ ]*)\ /app2before    \1\ /app2after
    server server_app2 app2.domain.com
backend backend_app3
    reqrep ^([^\ ]*)\ /app3before    \1\ /app3after
    server server_app3 app3.domain.com