Oct 27, 2017 Setting up HAProxy on Mac is not complicated. Check out how to build it from source and run it locally. Costa - Oct 27, 2017. Tags: haproxy Hey, Since 2016, a great Lua script has been used by many people deploying HAProxy instances that need to allow LetsEncrypt certificates generation: haproxy-acme-validation-plugin. To install HAProxy from source on a Mac, we need to follow some steps: install HAProxy dependencies (you can discover these using brew info haproxy if you have brew); gather the source code from the official website; compile the code using a set of flags that will allow us to build with the proper Lua support.
haproxy.cfg
global |
log127.0.0.1 local0 |
log127.0.0.1 local1 debug |
#log loghost local0 info |
maxconn4096 |
#chroot /usr/share/haproxy |
#daemon |
#debug |
#quiet |
defaults |
log global |
mode http |
option httplog |
option dontlognull |
retries3 |
option redispatch |
maxconn2000 |
timeout connect5000 |
timeout client50000 |
timeout server50000 |
frontend localnodes |
bind *:8000 |
mode http |
default_backend nodes |
backend nodes |
mode http |
balance roundrobin |
option forwardfor |
http-request set-header X-Forwarded-Port %[dst_port] |
http-request add-header X-Forwarded-Proto https if { ssl_fc } |
option httpchk HEAD / HTTP/1.1rnHost:localhost |
server server1 192.168.1.135:3000 check |
Setup & Install
Install HAProxy from Homebre: |
`brew install haproxy` |
For full reference: |
https://serversforhackers.com/load-balancing-with-haproxy |
commented Jul 25, 2018
thx for the gist! I needed to install from source and have Lua support to, so I wrote this quick article: https://ops.tips/blog/installing-haproxy-lua-macos/ I hope it helps! |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Create Subnet with 2 Web server VMs
Use the normal way of creating VM instances and add 2 VMs running a webserver into a single subnet
Install Lbaasv2 using Haproxy driver
Install lbaasv2-agent
Install the lbaasv2-agent on all controllers
Install the lbaas_agent.ini file
Update the
/etc/neutron/lbaas_agent.ini
to say the followingIn
/etc/neutron/neutron.conf
on all controllers apply the following diff:Restart Neutron servers
Configure a LoadBalancer
Create the Loadbalancer
First determine the Subnet ID that contains the hosts you wish to load balance to.
Notice that the Operational status is ONLINE but there are no listeners. Listeners are ports you want the load balancer to manage and balance traffic to. Example HTTP Port 80.
The Mitaka LBAAS doc says that you should be able to ping the
vip_address
. With OVS you cannot do that. It is because the lbaas network namespace is not created. This is what its like right nowTo create a ip netns namespace add a listener to the loadbalancer object.
Notice above that the
qlbaas-xxxx
namespace has the same ID as the name of the ID of the loadbalancer. In this case it is 33fcb82e-ab1d-4c71-90b4-6ce04998b993
.Now it is possible to ping a test VM from the loadbalancer. This is different than what the Mitaka Docs says.
Next create a security group that allow the VIP to accept HTTP traffic.
Apply the security group on the VIP port of the loadbalancer
Now add a loadbalancer pool and pool members.
At this point it is possible to test the loadbalancer. But not in the way the Mitaka Docs say. Run the ping test using the
ip netns exec
command.Next configure a floating IP for the VIP
First figure out an floating IP ID to assign to the VIP port id. Run
neutron floatingip-list
to get an empty floating id slot.Let's use the ID associated with
10.109.3.139
. And next get the VIP port id which is 458fac9d-755e-4c10-ba54-2186076059a4
With the floating IP id and vip_port_id, assign the VIP a floating IP of 10.10.3.139.
Now from the openstack controller bash terminal, use
curl
to access the VIP floating IP. You should see that load-balancing should work from the VIP floating IP.