Search by

yireo / magento2-salesblock2-by-ip

yireo

Block transactions based on IP matching

Package info

github.com/yireo/Yireo_SalesBlock2ByIp

Homepage

Type:magento2-module

pkg:composer/yireo/magento2-salesblock2-by-ip

Fund package maintenance!

yireo

www.paypal.me/yireo

Statistics

Installs: 1 443

Dependents: 0

Suggesters: 1

Stars: 2

Open Issues: 0

3.0.0 2026-11-25 16:53 UTC

This package is auto-updated.

Last update: 2026-11-29 21:01:49 UTC


README

Magento version PHP version License Latest Version

This module is a helper-module for the Yireo_SalesBlock2 extension, that allows you to block orders from being placed, based on specific rules defined in the Magento Admin Panel.

This specific module allows you to match by a specific IP pattern. The following patterns are supported:

  • 192.168.1.1 or 2001:db8::1 = Direct IP matches (IPv4 and IPv6, in any notation)
  • 192.168.1.0/24 or 2001:db8::/32 = IP ranges in CIDR notation
  • 192.168.1.1 - 192.168.1.10 = Explicit IP ranges
  • * = Every visitor

Multiple patterns can be separated by a newline, ,, ; or |.

Be careful with *: a rule with this pattern blocks orders from every visitor of the store. Partial wildcards like 192.168.1.* are not supported. Use a CIDR range like 192.168.1.0/24 instead. Invalid patterns (like 192.168.1.*, 192.168.1.0/33 or a reversed range like 192.168.1.10 - 192.168.1.1) are rejected when saving a rule. Invalid patterns that were saved with an older version are skipped and never match.

Installation

To install this module, use the following commands. First, install this module using composer. Note that this step will fail if the Yireo_SalesBlock2 is not installed yet.

composer require yireo/magento2-salesblock2-by-ip

Once this module is installed via composer, you can enable it:

./bin/magento module:enable Yireo_SalesBlock2ByIp

There are no further steps to take. The Yireo_SalesBlock2 module automatically picks up on things.

Client IP detection and reverse proxies

This module reads the client IP from REMOTE_ADDR only. The X-Forwarded-For header can be set to any value by a client, so it is ignored by default, even when Magento core is configured to use it (Magento core uses the leftmost IP of that header, which a blocked visitor could fake to get past an IP rule).

When Magento runs behind a reverse proxy (load balancer, CDN, Varnish), add the IP addresses of your proxies to the setting Trusted proxies under Stores > Configuration > Yireo > Yireo SalesBlock. When a request comes from a trusted proxy, the rightmost IP in the X-Forwarded-For header that is not a trusted proxy is used as the client IP. This setting is shared with Yireo_SalesBlock2ByGeo.

Current status

Static Tests Unit Tests Integration Tests Playwright DI Compilation