Devour
Devour

Reputation: 51

Setup of a load balancer of 2 play framework instances

I made an app (name: osc_poc) with PLAY Framework 2.2.1, and I copy the source folder to another destination to make a second instance of the app.

I start the apps with two terminals with different ports:

play            -> to launch the play console in each terminal
run 9850        -> to deploy the first app with port 9850 in terminal 1
run 9851        -> to deploy the second app with port 9851 in terminal 2

Then I installed Apache HTTPD server 2.2.25 with configuration as follow:

In httpd.conf:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

In httpd-vhosts.conf:

<VirtualHost osf_poc.com:80>
  ServerName osf_poc.com
  <Location /balancer-manager>
    SetHandler balancer-manager
    Order Deny,Allow
    Deny from all
    Allow from .osf_poc.com
  </Location>
  <Proxy balancer://mycluster>
    BalancerMember http://localhost:9850
    BalancerMember http://localhost:9851 status=+H
  </Proxy>
  <Proxy *>
    Order Allow,Deny
    Allow From All
  </Proxy>
  ProxyPreserveHost On
  ProxyPass /balancer-manager !
  ProxyPass / balancer://mycluster/
  ProxyPassReverse / http://localhost:9850/
  ProxyPassReverse / http://localhost:9851/
</VirtualHost

And I don't know what to launch to go to load balancer ip...

If I go to:

http://localhost:9850/

I can see the first app

And if I go to:

http://localhost/

I can see the message It Works from Apache...

Please can you help me find a solution ? Thanks

Upvotes: 2

Views: 1486

Answers (1)

Devour
Devour

Reputation: 51

SOLVED with configuration as follow:

In httpd.conf:

Include conf/extra/httpd-vhosts.conf

In httpd-vhosts.conf (as first VirtualHost Block):

<VirtualHost *:80>
  ServerName osf_poc.com
  <Location /balancer-manager>
    SetHandler balancer-manager
    Order Deny,Allow
    Deny from all
    Allow from .osf_poc.com
  </Location>
  <Proxy balancer://mycluster>
    BalancerMember http://localhost:9850
    BalancerMember http://localhost:9851 status=+H
  </Proxy>
  <Proxy *>
    Order Allow,Deny
    Allow From All
  </Proxy>
  ProxyPreserveHost On
  ProxyPass /balancer-manager !
  ProxyPass / balancer://mycluster/
  ProxyPassReverse / http://localhost:9850/
  ProxyPassReverse / http://localhost:9851/
</VirtualHost

Just need to launch http://localhost/ to be balanced !

Don't know if the following code is necessary:

ServerName osf_poc.com
  <Location /balancer-manager>
    SetHandler balancer-manager
    Order Deny,Allow
    Deny from all
    Allow from .osf_poc.com
  </Location>

Thanks all

Upvotes: 2

Related Questions