I'm running my servers on Red Hat Enterprise Linux 6.6, and thus haproxy is available as an RPM, installable thusly: -
yum install -y haproxy
which makes life easier.
There's not much to it, apart from the binary: -
ls -al `which haproxy`
-rwxr-xr-x 1 root root 394200 Jul 10 2013 /usr/sbin/haproxy
and a sample default configuration file: -
/etc/haproxy/haproxy.cfg
However, for now, I'm using a customised configuration file: -
configuration.conf
# Simple configuration for an HTTP proxy listening on port 80 on all
# interfaces and forwarding requests to a single backend "servers" with a
# single server "server1" listening on 127.0.0.1:8000
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8100
default_backend servers
backend servers
balance roundrobin
server server1 127.0.0.1:8080 maxconn 32
server server2 127.0.0.1:8081 maxconn 32
With this in place, I can start haproxy as follows: -
haproxy -f configuration.conf
and .... nothing obvious happens :-)
However, I do have a pair of IBM HTTP Server instances running, each with its own unique set of configuration files, logs and documents, separated thus: -
/opt/IBM/HTTPServer/conf1/httpd.conf
/opt/IBM/HTTPServer/logs1/
/opt/IBM/HTTPServer/htdocs1/
/opt/IBM/HTTPServer/logs1/
/opt/IBM/HTTPServer/htdocs1/
/opt/IBM/HTTPServer/conf2/httpd.conf
/opt/IBM/HTTPServer/logs2/
/opt/IBM/HTTPServer/htdocs2/
/opt/IBM/HTTPServer/logs2/
/opt/IBM/HTTPServer/htdocs2/
with an index.html file suitably edited to contain: -
...
<tr>
Hello from IHS1
</tr>
...
Hello from IHS1
</tr>
...
and: -
...
<tr>
Hello from IHS2
</tr>
...
Hello from IHS2
</tr>
...
respectively.
When I hit the load balancer URL ( aka the service name/port ): -
I get: -
when I reload the page, I get: -
proving that haproxy is balancing load, via the round-robin mechanism.
Next step is to get haproxy to use a self-signed SSL certificate, terminating SSL there, before establishing a new SSL tunnel to IHS using a different self-signed certificate
But that's a job for later .....
Meantime, I have some light reading: -
This might also be useful when I get around to doing this with my own domain: -
etc.
No comments:
Post a Comment