Pagoda Panel WordPress Blog Blocking Mainland IPs

This guide details how to block mainland China IPs using Nginx and Pagoda Panel to secure your cross-border e-commerce website and comply with regional website access policies. Learn how to set up IP blacklists and customize HTTP response status codes (e.g. 403 Forbidden) to prevent unwanted regional access to your website.

1, first of all, first in Nginx to add the mainland IP shielding code

Log in to the Pagoda panel, find the Software Store, select Settings behind Nginx, and tap the

Pagoda Panel WordPress Blog Blocking Mainland IPs

Open Settings and select Configuration Modifications on the left side of the http The following code is added to the block for blocking mainland IP addresses, as shown below

Pagoda Panel WordPress Blog Blocking Mainland IPs
# Define a blacklist of IP address segments to be blocked
    geo $block_cn {
        default 0;
        # IP address segment blocking range (pointing to uploaded IP data file)
        include /www/wwwroot/ipdata.txt;
    }

Note: include denotes a reference, followed by the address of the uploaded IP data file ( IPdata.txt file download link)

Download the ip data file in parentheses above, and upload ipdata.txt to the /www/wwwroot/ directory, which corresponds to the path written in the code.

Pagoda Panel WordPress Blog Blocking Mainland IPs

2, add the blocking code in the website that needs to block the mainland IP.

Find the website that needs to block mainland IP in the Pagoda, click the setting behind it.

Pagoda Panel WordPress Blog Blocking Mainland IPs

Open Settings and add a code to block mainland IPs:

Pagoda Panel WordPress Blog Blocking Mainland IPs
if ($block_cn) {
            return 403; # block mainland IP access, return 403 forbidden
        }

Add the above code in the same place as I did, where 403 is the status code returned if access is not possible, you can write 403, 404, 502, etc.

So far, open your website to test, with a continental IP access to your website domain name, it will prompt 403 no right to access.


Contact Us
Can't read the article? Contact us for a free answer! Free help for personal, small business sites!
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
Posted by photon fluctuations, retweeted with attribution:https://www.361sale.com/en/8604/

Like (0)
Previous April 22, 2024 am10:55
Next April 22, 2024 pm2:14

Recommended

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

020-2206-9892

QQ咨询:1025174874

E-mail: info@361sale.com

Working hours: Monday to Friday, 9:30-18:30, holidays off

Customer Service
In order to facilitate global user registration and login, we have canceled the telephone login function. If you encounter login problems, please contact our customer service for assistance in binding your email address.