Ubuntu 14.04
Sponsored Link

Use mod_proxy #2
2016/02/03
 
Enable mod_proxy module to configure reverse proxy settings. This example is based on the environment below.
(1) www.srv.world [10.0.0.31] - Web Server#1
(2) node01.srv.world [10.0.0.51] - Web Server#2
This example set servers that requests to (1)Web server forward to / on (2)webserver.
[1] mod_proxy is included in apache2 package by default, so it's possible to configure quickly.
root@www:~#
a2enmod proxy proxy_http

root@www:~#
vi /etc/apache2/mods-enabled/proxy.conf
# add into <IfModule mod_proxy **> - </IfModule>

<IfModule mod_proxy.c>
    ProxyRequests Off
    <Proxy *>
        Require all granted
    </Proxy>
    ProxyPass / http://node01.srv.world/
    ProxyPassReverse / http://node01.srv.world/

root@www:~#
/etc/init.d/apache2 restart

* Restarting web server apache2
...done.
  Access to frontend server to make sure backend server responses like follows.
[2]
It's possible to configure load balancing settings.
(1) www.srv.world [10.0.0.31] - Web Server#1
(2) node01.srv.world [10.0.0.51] - Web Server#2
(3) node02.srv.world [10.0.0.52] - Web Server#3
This example shows to configure servers that http requests to (1)Webserver are forwarded to (2)Webserver and (3)Webserver.
root@www:~#
a2enmod proxy proxy_http lbmethod_byrequests

root@www:~#
vi /etc/apache2/mods-enabled/proxy.conf
# add into <IfModule mod_proxy **> - </IfModule>

<IfModule mod_proxy.c>
    ProxyRequests Off
    <Proxy *>
        Require all granted
    </Proxy>
    # specify the way of load balancing with "lbmethod". it's also possible to set "bytraffic".
    ProxyPass / balancer://cluster lbmethod=byrequests
    <proxy balancer://cluster>
        BalancerMember http://node01.srv.world/ loadfactor=1
        BalancerMember http://node02.srv.world/ loadfactor=1
    </proxy>

root@www:~#
/etc/init.d/apache2 restart

* Restarting web server apache2
...done.
  Access to frontend server to make sure backend servers responses like follows.
Matched Content
 
Tweet