This repository contains a set of containers and instructions for setting up a HAProxy demo environment.
You will need to deploy at least 2 containers for running the demo, a single web server, and a single api server with local databases. Alternatively you may deploy multiple web and api servers along with an external mongodb database.
Build the container with:
cd frontend
docker build -t hapeeworld-fe:latest .
Run the container in development mode (make changes in real time)
docker run --rm -ti --entrypoint /bin/bash -v ~/hapee-webapp/frontend/app/:/usr/app --env NODE_ENV=development hapeeworld-fe:latest
Inside the container execute /usr/app/run.sh
to start the node app
To run the container in production mode, simply execute
docker run --rm -d hapeeworld-fe:latest
Build the container with:
cd middleware
docker build -t hapeeworld-mw:latest .
Run the container in development mode (make changes in real time)
docker run --rm -ti --entrypoint /bin/bash -v ~/hapee-webapp/middleware/app/:/usr/app --env NODE_ENV=development hapeeworld-mw:latest
Inside the container execute /usr/app/run.sh
to start the node app
To run the container in production mode, simply execute
docker run --rm -d hapeeworld-mw:latest
If you want to deploy more than one frontend, then you should deploy an external mongo database somewhere and provide a connection URL to the frontend containers by setting a DATABASE environment variable. Eg:
docker run --rm -d --env DATABASE=mongodb://192.168.1.100:27017/blog hapeeworld-fe:latest
If you need to setup a new cluster and deploy HAPEE nodes, then follow these steps, otherwise you can skip to Configure the cluster below.
- Open the Fusion UI and navigate to Infrastructure -> Clusters. Then either create a new cluster for your HAPEE nodes to join or edit an existing cluster. Do one of the following:
- Click the
New Cluster
button and give your cluster a name - Click the
Edit
icon for the cluster you wish to use
- Click the
- Ensure that the cluster has the correct HAPEE license key set
- Ensure the
Configuration Validation
section is set to the HAProxy Enterprise version you want. - Ensure that the
Cluster Membership
section hasAuto Join
enabled- If the HAPEE node is behind
NAT
device, then also selectRelaxed Node Joining
- If the HAPEE node is behind
- Ensure a
Bootstrap Key
is enabled. Click theGenerate Bootstrap Key
if it isn't.- If this is a new cluster, then you need to click
create
and then come back in via theEdit
icon before you can generate a key.
- If this is a new cluster, then you need to click
- Click
Update
If you are deploying HAPEE on local or cloud infrastructure (Bare metal or Virtual Machines), then you will need to deploy and configure the Linux hosts first. Once deployed, follow these steps:
- Open the Fusion UI and check that you are working on the correct cluster. The current cluster name is shown in the toolbar across the top of the screen.
- Navigate to Infrastructure -> Nodes and click
Add Node
in the top right - Click in the
Bare metal
text window to copy the installation script - Using a SSH session connect to the host where HAPEE is to be deployed and paste the script contents, and then press
<return>
. - If the information presented looks correct, then press
Y
to begin the installation. - Repeat steps 4 and 5 for any other nodes you want to add to this cluster.
- Once complete the node should appear in the Fusion UI.
Once of the many great advantages provided by Fusion are the analytics and log collection features. To make best use of features like the Request Explorer
we first need to setup log collection. Follow these steps to do so:
- Open the Fusion UI and navigate to Fusion Admin -> Log Export Targets
- Click the
Add Log Export Target
button - Ensure that the
Haproxy
checkbox is selected. - Give the target a name eg "hapeelogs".
- In the
Target Hostname/IP
box enter the IP or hostname of your Fusion instance - Set the
Target Port
as the syslog port 514 - And then select
TCP
as the protocol, orUDP
if you prefer. - Click on the
Create
button
Next we need to configure your cluster to use the new log target
- Navigate to Infrastructure -> Clusters
- Click the
Edit
button for your cluster - Scroll down to the
Other Settings
section - Set the
Log Export Target
to your newly configured target - Ensure the
Send HAProxy logs
option is enabled - Click the
Update
button.
The demo site uses a number of auxiliary files which configure how the site and HAProxy behave. Some of the settings take initial values from maps
and are then dynamically updated from a special /sysadmin
page on the site itself.
Take a look at the following files and customize as necessary
- fusion/maps/hapeeworld-site-settings.map
We need to upload several files, prior to uploading the structured HAProxy configuration.
- Open the Fusion UI and navigate to
Advanced Mode
->Files
->Map Files
- Click the
Add New Map File
button - Upload the file
fusion/maps/hapeeworld-site-settings.map
Next we want to upload out LUA script(s) and error file(s)
- Open the Fusion UI and navigate to
Advanced Mode
->Files
->General Files
- Click the
Add New General File
button - Upload the file
fusion/lua/site-settings.lua
- Upload the file
fusion/errors/error-404-json.http
- Upload the file
fusion/errors/error-503-json.http
Fusion has a number of interfaces and sections that enable the user to manage HA Proxy configuration elements, but it can also accept a "raw configuration"
format, which is what we're going to deploy next.
- Open the Fusion UI and navigate to Advanced Mode -> Config Edit
- Ensure you are in the
HAProxy
view and not theStructured
view - Delete the current content of the code editing window
- Copy and paste the contents from
fusion/hapeeworld-fusion.config
- Click the
Submit
button.