Filter by country




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 board and makes the board’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.

Blocking access

To traffic from unwanted countries, this extension shows a blocked message, but will present standard board headers and footers. Please note that links show will simply return users back to this page. This is the standard blocked message:

No access screen
No access screen

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.

No access with login option
No access with login option

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.

Settings page, version 1.0.15
Settings page, version 1.0.15
Statistics page, version 1.0.15
Statistics page, version 1.0.15

Other features

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, blocked and allowed from restricted country 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. Statistics can easily be reset on the statistics page.
  • 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,
  • Test mode. This extension has a test feature where you can pretend all IP traffic is from an IP you specify, then see the results on the statistic page if you enable statistics. Be careful when using this, as you may block legitimate traffic and confuse users. Blank out the field immediately after testing.

Language support

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 board until it shows up as an approved extension in’s extension database.

Downloads and support

You can participate in the discussion on my 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.

If you administer a phpBB board, you should find my book Mastering phpBB Administration invaluable. Learn lots of tips, tricks and secrets I learned from serving over 400 clients. Paper and Kindle versions available.