Published 10 days ago
Published 10 days ago
xiaibing wang
Updated 10 days ago
0
The SafeLine WAF High Availability solution ensures business continuity and guarantees the availability of SafeLine. This tutorial introduces how to build a high-availability WAF cluster using SafeLine's master-slave synchronization feature.
Considering the continuous security protection requirements of enterprise applications and the business interruption risks caused by single points of failure, a high-availability WAF protection solution is needed. This is especially important in the following scenarios:
Through master-slave configuration synchronization, SafeLine's website applications, engine rules, black/white rules, etc are automatically synchronized to different slave nodes in near real-time. Specific implementation methods and features:
Server information used in this tutorial:
Get Synchronization Command
Modify Communication Address
Copy Synchronization Command
Execute the synchronization command on the slave node
Expected wait time is 1-2 minutes. The master node interface will show:
The slave node interface will show:
When the last synchronization time updates to within the last one or two minutes, you can verify the synchronization status of website applications and various protection configurations on the slave node.
After completing the master-slave configuration of SafeLine WAF, you can use Nginx to configure load balancing to distribute traffic to master and slave nodes. Nginx is a high-performance HTTP and reverse proxy server, making it an excellent choice for load balancing.
Install Nginx on the load balancer server:
1# CentOS/RHEL 2yum install nginx 3 4# Ubuntu/Debian 5apt-get install nginx
Edit the Nginx configuration file /etc/nginx/nginx.conf
or create a new configuration file:
1http { 2 upstream safeline_cluster { 3 ip_hash; # Use IP hash algorithm to ensure requests from the same client are always sent to the same backend server 4 server 172.28.222.122:80; # Master node 5 server 172.28.222.123:80; # Slave node 6 } 7 8 server { 9 listen 80; 10 server_name your-domain.com; # Replace with your domain name 11 12 location / { 13 proxy_pass http://safeline_cluster; 14 proxy_set_header Host $host; 15 proxy_set_header X-Real-IP $remote_addr; 16 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 17 proxy_set_header X-Forwarded-Proto $scheme; 18 } 19 } 20}
ip_hash
directive ensures that requests from the same IP are always forwarded to the same backend server, which is crucial for WAF session persistenceupstream
block1# Test configuration file syntax 2nginx -t 3 4# Start Nginx 5systemctl start nginx 6 7# Enable auto-start on boot 8systemctl enable nginx
Point your domain name to the IP address of the server running the Nginx load balancer. After DNS propagation, test normal access through the domain name.
Through the above configuration, we have successfully built a high-availability SafeLine WAF cluster. This solution not only provides continuous security protection capabilities but also achieves automatic switching when nodes fail, ensuring stable operation of business systems. In actual deployment, it's recommended to choose an appropriate number of nodes based on business scale and requirements, and regularly conduct failure drills to verify the reliability of the high-availability solution. At the same time, attention should be paid to monitoring and alerting to promptly discover and handle potential issues, providing more reliable security protection for business systems.
Q: Are there other SLB solution options?
A: SLB solutions are not limited, common cloud vendor solutions can be chosen, or even simple Nginx can be used.
Q: Why does it always show "Synchronizing"?
A: "Synchronizing" only indicates that the master-slave synchronization mode is running normally, not the data synchronization completion status. Therefore, there are only two states: synchronizing and not synchronized.
Q: Can slave nodes edit configurations?
A: No. Slave nodes are read-only and can only follow master node configurations.
Q: Do slave nodes need separate licenses?
A: Yes, each slave node needs a separate license.
Q: Why hasn't the last synchronization time updated or why is there a large time gap?
A: Check if there are obvious errors in the master-slave mgt container logs, or try unbinding and re-synchronizing.
Q: Can master and slave nodes receive traffic simultaneously?
A: Yes.