Configure mod_proxy#2
2015/08/03
|
Enable mod_proxy module to configure reverse proxy settings. This example is based on the environment below.
(1) www.server.world [10.0.0.31] - Web Server#1
(2) node01.server.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 httpd package and it is enabled by default, so it's possible to configure quickly. |
# module is enabled by default
[root@www ~]#
grep "mod_proxy" /etc/httpd/conf.modules.d/00-proxy.conf
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so ..... LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
[root@www ~]#
vi /etc/httpd/conf.d/r_proxy.conf
# create new
<IfModule mod_proxy.c> ProxyRequests Off <Proxy *> Require all granted </Proxy>
# backend server and forwarded path
ProxyPass / http://node01.server.world/ ProxyPassReverse / http://node01.server.world/ </IfModule>
systemctl restart httpd
|
Access to frontend server to make sure backend server responses like follows. |
[2] |
It's possible to configure load balancing settings.
(1) www.server.world [10.0.0.31] - Web Server#1
This example shows to configure servers that http requests to (1)Webserver are forwarded to (2)Webserver and (3)Webserver.(2) node01.server.world [10.0.0.51] - Web Server#2 (3) node02.server.world [10.0.0.52] - Web Server#3 |
[root@www ~]#
vi /etc/httpd/conf.d/r_proxy.conf
# create new
<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.server.world/ loadfactor=1 BalancerMember http://node02.server.world/ loadfactor=1 </proxy> </IfModule>
systemctl restart httpd
|
Access to frontend server to make sure backend servers responses like follows. |
Nenhum comentário:
Postar um comentário