Magento 2 Geo Blocking: Control Countries and IP Ranges
SKU: GEOBLOCKING1
- block, redirect or show a notice for countries and IP ranges
- exceptions for search engine crawlers, admin and payment services
- whitelist or blacklist mode, rules per store view
- access log with country, rule and timestamp
Einmaliger Kauf · inkl. 12 Monate Updates · zzgl. MwSt.
Magento 2 Geo Blocking: control access by country and IP range
With the Mironsoft Magento 2 Geo Blocking you decide which visitors may open your store from which country or IP range. You can block access, redirect to another store view or domain, or show only a notice. Exceptions for search engine crawlers, the admin area and payment services keep operations safe. The check runs early in the request, and the notice appears in the Hyvä theme with Alpine.js. Magento 2 Geo Blocking is configured per store view.
Block countries
Blacklist for single countries or whitelist that admits only selected countries.
IP ranges
Single IPs and network ranges (CIDR) can be blocked or allowed in addition.
Redirect instead of block
Visitors from a country reach the matching store view, domain or a notice page.
Exceptions
Crawlers, admin paths, payment callbacks and your own IPs always stay reachable.
Notice page
Friendly text instead of an empty error page, with a correct status code and editable per language.
Log
Every hit is logged with country, rule and timestamp, without storing the full IP.
Why shops control access by country
There are many reasons not to serve visitors from certain countries: you do not deliver there, hold no licenses for brands or content, want to fend off bot traffic from certain regions or must separate prices and ranges per market. Operators therefore look for Magento 2 Geo Blocking that does not paralyse the whole store.
A blunt block at server level easily hits search engine crawlers or payment services and then hurts ranking and revenue. Magento 2 Geo Blocking therefore works with rules and exceptions you maintain in the admin.
Magento 2 Geo Blocking: countries and IP ranges in one rule table
Each rule links one or more countries, optionally IP ranges, and a store view to an action: block, redirect or show a notice. In whitelist mode only the named countries are allowed, in blacklist mode only the named ones are blocked. The country is determined by a local geo-IP database in MMDB format that you load; there is no external lookup per visit.
- Whitelist or blacklist, per store view
- Single IPs and CIDR ranges
- Local geo-IP database, no lookup per visit
Block, redirect or just show a notice
Not every hit has to mean a block. When redirecting, the visitor reaches the matching store view or domain of your store. With a notice he sees a page with your text, for example that orders from his country are not possible. The page is delivered with the matching HTTP status. A cookie option remembers the choice so the visitor is not redirected on every request.
- Redirect to store view or domain
- Notice page with own text per language
- Visitor choice remembered by cookie
Exceptions for crawlers, admin and payment services
So the store does not drop out of the index by accident, search engine crawlers can be exempted from rules. The admin area, maintenance and cron calls as well as callbacks from your payment services stay reachable too. You enter your own office IPs as a permanent exception. A test field in the admin shows how a given IP or country would be treated.
- Crawler exception can be switched on and off
- Admin, cron and payment callback paths free
- Test field for country or IP
Log, privacy and evaluation for geo blocking
The log shows which rule triggered how often, broken down by country and period. Only the country and a shortened form of the IP are stored, you set the retention period, and a cron job deletes older entries. That helps to spot false positives. When blocking consumers, observe the EU rules on geo-blocking; the legal review remains with the shop operator.
- Hits per rule, country and period
- Shortened IP, retention adjustable
- Automatic cleanup by cron
Where Magento 2 Geo Blocking is used in daily business
Typical situations in which Magento 2 Geo Blocking with country-based access rules makes sense.
Delivery only to target countries
Visitors from countries without delivery see a friendly notice instead of order attempts that are cancelled later.
Market and domain separation
Visitors from Austria land on the Austrian store view, visitors from Switzerland on the matching domain.
Bot and fraud defence
Conspicuous traffic from regions without customers can be blocked without hitting crawlers and payment services.
Licence and brand rights
Content or brands that may only be sold in certain markets stay visible there.
Magento 2 Geo Blocking: without and with the module
The difference from a blunt block at server level.
| Topic | Without the module | With Mironsoft Geo Blocking |
|---|---|---|
| Granularity | Whole store or nothing | Rules per country, IP range and store view |
| Action | Error page only | Block, redirect or notice |
| Exceptions | Crawlers and payment services often hit | Targeted exceptions in the admin |
| Traceability | No evaluation | Log per rule and country |
| Maintenance | Server configuration by an admin | Rule table in the Magento admin |
How we set up Magento 2 Geo Blocking for you
The process after you place your order.
Alignment
You tell us target countries, blocking wishes, store views and exceptions such as office IPs and payment services.
Installation
We install the module, load the geo-IP database and set up Magento 2 Geo Blocking for your store views.
Notice pages
We write the notice texts per language and define status codes and redirect targets.
Testing
We test Magento 2 Geo Blocking with test IPs, crawler exception, admin access and payment callbacks.
Handover
Your team gets an introduction to the rule table, exceptions and log.
Scope compared with shipping restrictions and payment rules
The Shipping Restrictions module by Mironsoft blocks shipping methods at checkout by product, group, country or postcode. The visitor can keep using the store. Magento 2 Geo Blocking, in contrast, controls page access itself, that is, whether someone from a country may see the store at all.
Payment method rules and general security modules stay untouched. All of them can be combined.
No download — personal setup instead
Geo Blocking is not listed here as a ready-made download file for self-installation. The purchase is a service commission: we get in touch after the purchase, install the module in your shop and agree on rules, exceptions and notice texts together with you.
Frequently asked questions
Everything important about rules, exceptions, log and the purchase process.
How can I block certain countries in Magento 2?
How can I redirect visitors by country to another store view in Magento 2?
Can I also block IP ranges?
Are search engine crawlers locked out?
Do admin and payment services stay reachable?
Where does the country mapping of the IP come from?
Is Magento 2 Geo Blocking legally safe?
Does it work with Hyvä?
How does the module differ from shipping restrictions?
Can I download and install the module myself?
Magento 2 Geo Blocking – Mironsoft