The redirect option is viable when there is a need to share Spotter Web servers among a high number of users. The redirection option redirects the user to the next free server, and the user can then use Spotter Web. In this case, traffic is also handled on said server, as opposed to when using HAProxy Load Balancer, when all traffic goes through the Load Balancer server.
Certifications are handled on each server by itself.
In the following example, we go through the installation of the redirect option using HAProxy on the Ubuntu Server LTS operating system (e.g., Ubuntu 24.04.4 LTS or newer).
Configuration
To proceed, you need to have Ubuntu Server installed and updated with the latest patches.
When this is done, you can make an SSH connection to the Ubuntu Server.
-
To install HAProxy, run the following command:
sudo apt install haproxy -y
-
Enable HAProxy to run automatically using the following command:
sudo systemctl enable haproxy
-
Make a backup of the original HAProxy configuration:
sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
-
Edit the HAProxy configuration using the command:
sudo nano /etc/haproxy/haproxy.cfg
-
Change the defaults-section current timeout values to these and add the missing ones:
timeout connect 5s
timeout client 24h
timeout server 24h
timeout tunnel 24h
-
Add this example configuration at the end of the file and change the backend server details:
# HAProxy Front End
frontend https_front
bind *:443 ssl crt /etc/haproxy/certs/site.pem
mode http
default_backend redirect_backend
# Spotter Web Servers Configuration
backend redirect_backend
mode http
balance roundrobin
# Define IIS servers with health checks
server web1 server1IP:443 check ssl verify none
server web2 server1IP:443 check ssl verify none
# Redirect only to available servers
http-request redirect location https://172.24.16.53 code 302 if { rand() lt 1073741824 } { srv_is_up(web1) }
http-request redirect location https://172.24.16.54 code 302 if { rand() ge 1073741824 } { srv_is_up(web2) }
# HAProxy Stats Page
listen stats
bind *:8404
mode http
stats enable
stats uri /
stats refresh 5s
stats auth admin:password
-
Save the configuration file, and then you can check the validity of the configuration by using the command:
sudo haproxy -c -f /etc/haproxy/haproxy.cfg
-
If the configuration is valid, you should get a message:
Configuration file is valid
-
Now you can restart HAProxy using the command:
sudo systemctl restart haproxy
-
Lastly, you need to open ports for the Ubuntu firewall if it is in use, using the commands:
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 8404
Now you can test making a connection to the HAProxy stats page to see if the system works as it should and can communicate with the backend servers.
You can access the HAProxy stats page using the server IP address or domain name and port 8404. (Example: http://serverip:8404).
After this, you can make a connection to the site and check that the redirection for Spotter Web is working as it should, and monitor the stats page.