For Cn2 line anomalies, use the Nginx reverse proxy disaster recovery solution.

Published: 2023-09-08

   Hong Kong data centers have relatively poor anti-attack capability due to relatively small outbound bandwidth. This is a common weakness of most Hong Kong data centers.CN2 has better stability, 163 lines are relatively cheaper, but their stability is somewhat worse than CN2. In special cases such as segment sweep attacks ( https://anquan.baidu.com/article/1343 ), the impact may be relatively wide.

If your Hong Kong server has relatively high stability requirements, and packet loss or slowdown for a certain period of time will seriously affect your business operations, we strongly recommend that you prepare a disaster recovery solution:

For example, set up a server on a backup line, keep data synchronized at all times, and switch seamlessly when a problem occurs. For instance, if your server is used for e-commerce business and is hosted in a Cn2 data center, we recommend that you set up a server on a 163 line. Regarding data synchronization: you can store data on both of the 2 machines, synchronize them regularly, and switch through domain name resolution when a fault occurs.

You can also use measures such as ngix reverse proxy, where no data is kept on the backup server, and only reverse proxy is used to switch traffic over.

There are many more disaster recovery solutions to choose from. For details, you can submit a ticket for consultation.


The following provides a mature Nginx reverse proxy disaster recovery solution:

1. Suitable for situations where the origin server has a network anomaly and cannot provide services (for example, a Hong Kong Cn2 line experiences packet loss on the mainland China Telecom line, while access from other carriers such as China Unicom and China Mobile, as well as from Hong Kong, is normal).

2. Set up a Hong Kong 163-line cloud server with the same configuration, and select the "CentOS7 pre-installed with BaoTa Panel" system and install it.

3. Then use ssh to remotely log in to the Hong Kong 163-line server, Ip-to-Ip reverse proxy settings(the example code targets 80 and 443 ports, other ports can be configured by referring to the example):

First, run vi /www/server/nginx/conf/nginx.conf

Then add the following code at the end of the file:

(In the example code, the Hong Kong Cn2 server IP is 1.1.1.1; the Hong Kong 163 line IP is 2.2.2.2, please have the user 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 to the IP of the newly opened 163-line server, and once the domain name resolution takes effect, normal access will be restored.


windows system uses software for offsite data synchronization (disaster recovery)