@machy wrote:
I am very new in this and I am trying to configure a load balancer for 2 web servers using HAProxy with 2 EC2 Instances. Let’s just say I can only work with 2 Instances, is it possible for me to hook this up with only 2 nodes?
I currently only have NodeA (x.x.x.1) and NodeB (x.x.x.2), I set up my HAproxy at NodeA listening to port 80. my full
haproxy.cfg
at NodeA looks like this.global log /dev/log local0 log 127.0.0.1 local0 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon stats socket /var/lib/haproxy/stats defaults mode http log global option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 errorfile 503 /etc/haproxy/errorfiles/503.http frontend http-in mode http bind *:80 default_backend webservers backend webservers mode http balance roundrobin server NodeA x.x.x.1 check port 80 server NodeB x.x.x.2 check port 80
as you can see from the configuration above, the load balancing doesn’t work because i cannot start up my Apache on NodeA because HAPorxy is taking up Port80. and I can only get NodeB but not NodeA.
I have tried changing the HAporxy port to listening to other port: Failed.
I have also tried changing my Apache Port to other port and have NodeA looks something likefrontend http-in mode http bind *:80 default_backend webservers backend webservers mode http balance roundrobin server NodeA x.x.x.1:81 check server NodeB x.x.x.2:81 check
but failed as well. I am now getting a 404 Bad Request at my browser.
some logs from HAProxy
x.x.x.1:53006 [18/Mar/2019:01:27:57.789] http-in webservers/NodeA 0/0/0/43/43 400 168 - - ---- 6/6/6/6/+1 0/0 "GET / HTTP/1.1"n x.x.x.1:53002 [18/Mar/2019:01:27:57.788] http-in webservers/NodeA 0/0/0/43/43 400 168 - - ---- 5/5/5/5/+1 0/0 "GET / HTTP/1.1"n x.x.x.1:52998 [18/Mar/2019:01:27:57.788] http-in webservers/NodeA 0/0/0/44/44 400 168 - - ---- 4/4/4/4/+1 0/0 "GET / HTTP/1.1"n x.x.x.1:52994 [18/Mar/2019:01:27:57.787] http-in webservers/NodeA 0/0/0/44/44 400 168 - - ---- 3/3/3/3/+1 0/0 "GET / HTTP/1.1"n x.x.x.1:52990 [18/Mar/2019:01:27:57.787] http-in webservers/NodeA 0/0/0/45/45 400 168 - - ---- 2/2/2/2/+1 0/0 "GET / HTTP/1.1"n x.x.x.1:52986 [18/Mar/2019:01:27:57.786] http-in webservers/NodeA 0/0/0/45/45 400 168 - - ---- 1/1/1/1/+1 0/0 "GET / HTTP/1.1"n x.x.x.1:57534 [18/Mar/2019:01:27:52.344] http-in webservers/NodeA 5441/1/0/46/5718 400 168 - - ---- 1/1/0/0/+1 0/0 "GET / HTTP/1.1"n
I am not sure if I am understanding the right concept.
But essentially I am asking if it is possible to load balance with only 2 nodes,
(eg. NodeA running HAProxy and Apache, Node B as secondary server)Would appreciate to know if my concept is wrong or any workaround with this set up.
Posts: 1
Participants: 1