load balancing
Herald van der Breggen <[email protected]>
| Newsgroups | gmane.network.tux |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have a question about how to setup load balancing in combination with
Tux. If you have a solution, please let me know!
In the more or less "standard" situation there is a user space webserver
(say apache) listening on port 8080 on localhost for requests that
cannot be handled by tux (e.g. requests for dynamic pages).
We would like to process the requests for dynamic pages on several
servers on a local network, while keeping tux on a frontend server. More
or less with a load balancing mechanism. So like this:
+----------+
+-----------------+ +----->| server 1 |
requests ---> | server with Tux | ----| +----------+
+-----------------+ | +----------+
+----->| server 2 |
| +----------+
etc
static pages internal lan, dyn pages
It seems like a natural choice (right?) so I guess (and hope) some of
you have found you a way to achieve a thing like this.
A few solutions crossed my mind:
1. Running Apache+mod_proxy on the tux server.
In this case apache does nothing but proxying the backend servers. This
solution is possible, no doubt. But a huge drawback is that is is not
easy manageable when you use mass virtual hosting with hundreds, if not
thousands of virtual hosts, because you cannot simply replace the
hostname in the url by "server1" or so: you would loose information
regarding which site the request is for. You could use a special server
specific prefix like "http://server1.hostname/dir/file.html?a=1" or so,
but that would mean that a lot of hostnames must be defined (one per
wwhost + backend server combination).
Maybe another way around is to proxy to
http://server1/hostname/dir/file.html?a=1 and than reconstruct the
original url on the backend servers using rewrite rules....
I don't see more simple setups...
2. iptables
I did not test it, but maybe a DNAT rule could help. E.g.
SERVER_NAME=192.168.1.1-192.168.1.3
$FROM_IP=127.0.0.1 (?)
$FROM_PORT=8080 (?)
iptables -t nat -A OUTPUT -d $FROM_IP --dport $FROM_PORT -j DNAT
--to-dest $SERVER_RANGE:80
I really don't know whether this can work and if this can work, which
values for FROM_IP and FROM_PORT should by used, because the way the
packets arrive at apache (localhost:8080) is still a bit spooky to me:
the listen statement and virtual host configuration of apache do not
match the same ip/port.
Do you have a solution, please let me know!
Thanks,
Herald