Skip to content

Magento 2 Geo Lock Manual

Geo Lock Cover


Out of the box Magento doesn't provide any possibility to allow/block the website for specific IPs or countries. It is supposed to be done by means of htaccess. To set it up correcly please check our special guide.

Magento 2 Geo Lock extension makes it possible to identify your shoppers' location and allow/deny them access to the store.

By means of this extension it is possible to:

  • Prevent any fraudulent store activities by blacklisting the IPs.

  • Manually specify countries to allow/deny accessing your site content.

  • Shape black/white IP lists.

  • Display 403 Access Denied text for users from the denied locations/ blacklisted IPs.

Requirements and Installation

Geo Lock supports both Community and Enterprise edition of Magento 2 starting from version 2.1. The current version of the Magento installed on your website can be found in the lower right corner of any backend page.

Magento 2 Version

Geo Lock has 2 separate ways of installation: via Composer or by copying the code.

Installation Via Composer

  1. Create a folder anywhere on your server (preferably not in the Magento installation directory). Put the zip archive into this folder.

  2. Use any SSH client to connect to your server. Navigate to the root Magento folder. Bear in mind that the user should write permissions to this folder and its subfolders.

  3. Add the folder with the extension's archive as a repository. For this, run the Composer command:

    composer config repositories.mageworx artifact {/ABSOLUTE/PATH/TO/FOLDER}


    composer config repositories.mageworx artifact /mageworx/extensions/zip

    This command will add these lines to your composer.json file

    "mageworx": {
        "type": "artifact",
        "url": "/mageworx/extensions/zip"
  4. Perform the command:

    composer require mageworx/module-geolockmeta
  5. Clear the compiled code and the cache:

    php bin/magento setup:upgrade
  6. To update the extension via composer perform the command:

    composer update mageworx/module-geolockmeta

Installation by copying the code

  1. Download the extension's package from your customer account, unzip it.

  2. Use any SSH client to connect to your server. Bear in mind that the user should write permissions to this folder and its subfolders.

  3. Upload all the files and folders from the extension's package to the root Magento folder.

  4. Via SSH, navigate to the root Magento folder and perform the command:

    php bin/magento module:enable MageWorx_GeoLock
  5. Clear the compiled code and cache:

    php bin/magento setup:upgrade
    php bin/magento cache:flush
    php bin/magento setup:static-content:deploy

Extension Configuration

Magento 2 Geo Lock Settings

To observe the extensions settings, go to STORES ⟶ Configuration ⟶ MAGEWORX ⟶ GeoIP Extensions.

Magento 2 Geo Lock Settings

All the extension configurations are provided under the Geo Lock tab.

They can be logically divided into 3 parts.

Enable the extension

If the clients observe some problems after the installation of the extension. they can easily disable its functionality by selecting No in the Enabled configuration setting.

Allow/block By Country

Magento 2 Geo Lock by Country

Here the store owner can either Allow access to some peculiar countries or Deny it for some regions. To select several countries one by one, hold the Ctrl key and click the items one by one. To select a group, hold the Shift key and select the first and the last option.

Whitelist/Blacklist IPs

Magento 2 Geo Lock by IP

Both White List and the Black List can be filled here. The wildcard symbol * can be used for IP arrays.

Special Cases

  1. If both whitelist and blacklist are populated, then only the whitelist will be used (only the mentioned IPs will be allowed to view the website, the Geo Lock by countries wouldn't be taken into consideration).

  2. If the same IP is in the white list and the black list, then it will be allowed as the whitelist has higher priority.

  3. If the store owner IP is specified in the blaclist, or is not provided in the whitelist, or is blocked in the countries settings, the frontend will be locked.

Magento 2 Geo Lock by IP

Nevertheless, the admin page will still be accessible so it can be removed without any problems.

Got Questions?

MageWorx offers FREE lifetime support and updates for any extension developed for Magento. Need help with the extensions? Feel free submit a ticket from 

MageWorx offers outstanding services developing custom-tailored solutions for Magento platform to attain your eCommerce objectives. Our professional impassioned team provides profound and custom oriented development of your project in a short timeframe.