Search code examples
authenticationliferayload-balancingip-addresshaproxy

I can sign in to Liferay using IP address but cannot login using the portal URL


I have two Liferay 6.2 instances that an HAProxy is in front of them for load balancing purposes. HAproxy exists on another server and has its own IP address. The portal URL points to the HAproxy load balancer. I can sign in using the IP address of any of the Liferay servers. When I want to sign in using the URL, I am successfully redirected to Sign In page of Liferay but after entering user/pass and clicking Sign In button, the Sign In page appears again without any error message, nither on UI nor on the Tomcat log. Based on the Tomcat log, the background sign in process works well, but it doesn't redirect to any proper page of the portal. Moreover, if I enter wrong credentials, no error messages are displayed and the Sign In page appears again.


Solution

  • HAproxy uses different algorithms for load balancing. Our initial set-up used 'roundrobin'. This algorithm works by using each server behind the load balancer in turns, according to their weights. Click here for more details. Regarding this algorithm, each HTTP response of a successful login on one Liferay instance redirects to another Liferay instance while it is not aware of the login request. By changing 'roundrobin' to 'source' the problem was resolved because this algorithm balances the load regarding the IP address of received HTTP requests. It dedicates each server to some clients. In other words, this algorithm prevents such situations that a client gets responses from different servers, so HTTP sessions don't get missed.