This extension filters traffic by country. An administrator can either allow traffic from selected countries only, or not allow any traffic from selected countries. It helps reduce unwanted traffic to a forum and makes the forum’s content entirely inaccessible to blocked countries.
The extension uses the free MaxMind GeoLite2 country database. The database examines the IP address of the user and determines the country of origin.
You must acquire a license key to download the MaxMind database. I recommend you do this before installing the extension. You must register on the MaxMind site, but you don’t have to pay for a licensed version of this database. In fact, it works only with the free GeoLite2 country database. You will get a set of one-time credentials that you should retain somewhere safe. You will also need to enter the license key on the extension’s settings page. Without a valid license key, the database cannot be downloaded by the extension.
Some boards attract a lot of spam, often times malicious robots from countries like Ukraine, Russia or Belarus trying to create spam accounts and spam posts. This extension may be part of this solution. Other boards really don’t want traffic from outside the country because their focus is strictly national, or applies only to a set of given countries. This extension can prohibit the rest.
There are other ways to block traffic by country. For example, CloudFlare has a paid service that can do this. These solutions have the advantage of keeping this traffic from ever hitting your site, which reduces server resources used. This extension though might be preferable, as it has features that allow registered users to login even if their country is blocked, if this feature is enabled.
To traffic from unwanted countries, this extension shows a blocked message, but will present standard forum headers and footers. Please note that links show will simply return users back to this page. This is the standard blocked message:
The administrator can allow registered users to login even if their access is from a blocked country. If so, they will see this blocked message, with an embedded login link that will work. No other links will work.
Administration Control Panel
Here is the administrator’s user interface for the extension. After installation, you will find it on the extensions tab in the Administration Control Panel.
The extension though has some unique and special features that make it more useful than a basic IP block:
- Ignore known bots. phpBB maintains a list of known bots (search engines). With this setting enabled, known bots are not counted in the statistics. Whether the bot can read content depends on the other settings.
- Logging. You can log all blocked page requests. The log entry will identify the user (which could be “Anonymous”, for guests), the IP used and the country. Invalid IPs are not counted. One downside is that this could make for some very large log tables.
- Statistics. You can keep statistics on the number of allowed and blocked page requests by country and see the details in a report. This too can result in some large tables. The statistics can be filtered by a relative range or an absolute range of dates. The columns can be sorted in ascending or descending sequence.
- Weekly automatic database update. The database is refreshed approximately once a week automatically using a phpBB cron. MaxMind refreshes the database on Tuesdays. To allow for timezone variations, this extension will attempt to retrieve the database on Wednesdays, but only if at least seven days have elapsed since the database was last refreshed.
- Checks all likely HTTP headers. Typically, the originating IP is in the REMOTE_ADDR header, which should always be present. Certain other HTTP headers may imbed IPs. For example, CloudFlare uses a HTTP_CF_CONNECTING_IP HTTP header. The IP in this header, if any, is also examined. If the IP corresponds to a country that should be blocked, the page request is blocked. IPs in the following HTTP headers are examined: HTTP_CF_CONNECTING_IP, HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR,
HTTP_X_FORWARDED, HTTP_X_CLUSTER_CLIENT_IP, HTTP_X_REAL_IP,
HTTP_X_COMING_FROM, HTTP_PROXY_CONNECTION, HTTP_FORWARDED_FOR,
HTTP_FORWARDED, HTTP_COMING_FROM, HTTP_VIA,
Currently English is the only language included.
A Dutch language pack provided by </Solidjeuh> is available.
If you have one to contribute, please let me know.
This extension is in release candidate status. You should not use it on a production forum until it shows up as an approved extension in phpbb.com’s extension database.
Downloads and support
You can participate in the discussion on my phpbb.com topic here.
You can always grab versions from my GitHub archive. If downloaded from GitHub, make sure to place it in a /ext/phpbbservices/filterbycountry directory.
- 1.0.12 (May 22, 2020)
- 1.0.11 (May 21, 2020)
- 1.0.10-rc (January 18, 2020)
- 1.0.9-beta (January 13, 2020)
- 1.0.8-beta (October 16, 2019)
- 1.0.7-rc (September 7, 2019)
- 1.0.6-rc (August 11, 2019)
- 1.0.5-rc (August 2, 2019)
- 1.0.4-rc (July 27, 2019)
- 1.0.3-beta (July 4, 2019)
- 1.0.2-beta (June 16, 2019)
- 1.0.1-alpha (June 4, 2019)
- 1.0.0-dev (May 28, 2019)