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

Image[1]-Pagoda Panel WordPress Blog Blocking Mainland IP - Photon Flux | Professional WordPress Repair Service, Global Coverage, Fast Response

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

Image[2]-Pagoda Panel WordPress Blog Blocking Mainland IP - Photon Flux | Professional WordPress Repair Service, Global Coverage, Fast Response
# 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;
}
# 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;
    }
# 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.

Image[3]-Pagoda Panel WordPress Blog Blocking Mainland IP - Photon Flux | Professional WordPress Repair Service, Global Coverage, Fast Response

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 at the back.

Image[4]-Pagoda Panel WordPress Blog Blocking Mainland IP - Photon Flux | Professional WordPress Repair Service, Global Coverage, Fast Response

Open Settings and add a code to block mainland IPs:

Image[5]-Pagoda Panel WordPress Blog Blocking Mainland IP - Photon Flux | Professional WordPress Repair Service, Global Coverage, Fast Response
if ($block_cn) {
return 403; # block mainland IP access, return 403 forbidden
}
if ($block_cn) {
            return 403; # block mainland IP access, return 403 forbidden
        }
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 free answers! 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
© Reprint statement
This article was written by Jack
THE END
If you like it, support it.
kudos0 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments