For Cn2 line anomalies, use the Nginx reverse proxy disaster recovery solution.
Published: 2023-09-08
Hong Kong data centers have relatively small outbound bandwidth, so their attack resistance is relatively poor. This is a common problem for the vast majority of Hong Kong data centers.CN2 is somewhat more stable; the 163 line is relatively cheaper, but its stability is somewhat worse than CN2. In special cases such as being subject to segment scanning attacks ( https://anquan.baidu.com/article/1343 ), the scope of impact may be relatively wide.
If your Hong Kong server has relatively high stability requirements, and if packet loss or slowdown for a certain period of time would seriously affect your business operations, our company strongly recommends that you prepare a disaster recovery solution:
For example, provision a server on a backup line and keep data synchronized at all times, so that seamless switching can be performed when a problem occurs. For example, if your host is used for e-commerce business and uses a Cn2 data center, we recommend that you provision a server on the 163 line. Regarding data synchronization: you can 2 place data on both machines, perform synchronization during normal times, and switch via domain name resolution when a failure occurs.
You can also usengix reverse proxy and other measures. The standby machine does not retain data; it only uses the reverse proxy to switch traffic over.
There are also more disaster recovery solutions to choose from. For details, you can submit a ticket for consultation.
Below is a relatively mature Nginx reverse proxy disaster recovery solution:
1. Applicable when the origin server has network abnormalities and cannot provide services (for example, the Hong Kong Cn2 line experiences packet loss on the mainland China Telecom line, while access through China Unicom, China Mobile, and the Hong Kong region is normal).
2. Provision a Hong Kong 163 line cloud server with the same configuration, select the "CentOS7 preinstalled with Baota Panel" system and install it.
3. Then ssh remotely log in to the Hong Kong 163 line server, and Ip-to-Ip reverse proxy settings( the sample code targets 80 and 443 ports; for other ports, you can configure them yourself by referring to the sample):
First, vi /www/server/nginx/conf/nginx.conf

Then add the code at the end of the file:
(In the sample code, the Hong Kong Cn2 server IP is: 1.1.1.1; the Hong Kong 163 line IP is: 2.2.2.2, Users please modify the IP addresses in the code according to the actual IP addresses)
stream {
proxy_connect_timeout 300s;
proxy_timeout 300s;
server {
listen 2.2.2.2:80;
proxy_pass 1.1.1.1:80;
}
server {
listen 2.2.2.2:443;
proxy_pass 1.1.1.1:443;
}
}
Then reload the nginx service: service nginx reload

Finally, point the domain name resolution to the newly provisioned 163 line server IP, and wait for the domain name resolution to take effect, after which normal access will be restored.
Use software for remote data synchronization on Windows system (disaster recovery)
