How to redirect to different servers based on login username?

What I want to do seems like it should be fairly simple. I would like to have one external address, and redirect to multiple different internal servers based on the login that the user uses.

That is, given users u1, u2, u3 and u4, I want them all to login to www.domain.com, and have users u1 and u2 internally redirected to internal1.domain.com and u3 and u4 redirected to internal4.domain.com.

The logged in user should also be passed through so that the internal site knows which user is logged in. The internal sites will not be externally addressable.

I have looked at Perlbal, and that seems to allow some of what I want, but I can't see any option to redirect based on the logged in user. Mod_proxy also does not seem to allow this level of control.

What other options exist, or how can I make the aforementioned options do what I want?


Apache's mod_proxy could, in fact, do exactly what you want.

Its session-stickiness reads from cookie values; if all of the application servers know which server a user needs to go to (I'm not really clear on how the user distribution is decided, but we'll assume that it's stored or calculable), then it's simple.

Any server could give the user their server cookie on the first request. Say apache throws them to internal1, but they should be on internal2; the cookie can be something like SERVERID set to server.internal2. On the second request, with the below config, apache will see the cookie and send the user to the BalancerMember backend that is attached to the route defined in the cookie.

<Proxy balancer://domain>
    BalancerMember http://internal1.domain.com route=internal1
    BalancerMember http://internal2.domain.com route=internal2
</Proxy>

ProxyPass / balancer://domain/ stickysession=SERVERID
ProxyPassReverse / balancer://domain/

Well I hope you have some programming knowledge...

The easiest way is to use a basic web server and make a login script using php/mysql.

When a user logs in you can use the header(Locaction: internalx.domain.com); to send the user to a different page.

To keep user data you can simply use cookies or (more advanced) cookies or one time links to the internal.domain.com server and use the same database for the sites.

You can google for login scripts or ask on stackoverflow.com for more info. But I assume since you allready have the internal sites that either you or someone you know has programming experience.