1
0
Fork 0
My old website. I completely made this one in bash-scripting.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
2.1 KiB

<b>Proxy HTTP requests in Apache 2.2 with mod_proxy and mod_balancer</b>
You can actually use an Apache web server as a front web server to proxy
specified requests to other web servers. For example to load balance your backend
servers or to make a failover system in case of an failure. Yes, we are talking
about high availability!
<b>Simple</b>
First enable the modules mod_proxy and mod_proxy_http. Now we can do a simple
request forward. Of course we use a Debian system, so to enable the proxy modules
we will do:
a2enmod proxy proxy_http
/etc/init.d/apache2 restart
Now we can make use of the proxy capabilities of Apache. Put the next part in
your virtual host or any other place.
ProxyPass /application http://servername:port/somethingelse/
ProxyPassReverse /application http://servername:port/somethingelse/
<b>Loadbalance and/or failover</b>
For this part we need some more modules. So we enable them. You can also enable
the ftp and ajp connectors if you need them. It's exactly the same as with the
mod_proxy_http.
a2enmod proxy proxy_http proxy_balancer
/etc/init.d/apache2 restart
Now we can have fun! The ProxyPreserveHost is technically not needed. But there
are some more options in the proxy module that makes life a little bit easier.
We will not proxy requests for /context/static. All the rest will be proxied to
the right server. Server1 is active now. Server2 is disabled. (maintenance?) So
if Server1 will fail, everybody is moved to a balanced cluster of Server3 and
Server4. I know, it's a little bit strange setup, but it's only an example.
ProxyPreserveHost On
ProxyPass /context/static !
ProxyPass /context balancer://clustername/something
&ltProxy balancer://clustername>
BalancerMember http://servername1:port lbset=0 route=server1
# The next server is temporary disabled.
BalancerMember http://servername2:port lbset=0 route=server2 status=+D
#
# Backupservers if other servers failed
BalancerMember http://servername3:port lbset=1 route=server3
BalancerMember http://servername4:port lbset=1 route=server4
&lt/Proxy>