
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
ipgeoblock-fixed
Advanced tools
Node-ipgeoblock helps you secure your Express application by intoducing the blacklist of IPs, the blacklist of countries or the whitelist of countries.
This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.
First, run npm install node-ipgeoblock for your application.
Then download the latest version of MaxMind GeoLite2 Country Database and save it somewhere in the way that you application can access it. Make sure you download the database in MaxMind DB format. We will use ./GeoLite2-Country.mmdb in the following examples.
The last step is to register node-ipgeoblock middleware in your Express (or Connect) application.
var ipgeoblock = require("node-ipgeoblock");
var app = express();
app.use(ipgeoblock({
geolite2: "./GeoLite2-Country.mmdb",
blocked: ["192.168.0.1", "192.168.0.3", "192.168.0.4"]
}));
var ipgeoblock = require("node-ipgeoblock");
var app = express();
app.use(ipgeoblock({
geolite2: "./GeoLite2-Country.mmdb",
blockedCountries: [ "FR", "GB", "DE" ]
}));
When Countries Blackist is used you allow access for all IPs except IPs assigned to the countres from the blacklist. The Country Code MUST be upper case ISO 3166-2 Code.
var ipgeoblock = require("node-ipgeoblock");
var app = express();
app.use(ipgeoblock({
geolite2: "./GeoLite2-Country.mmdb",
allowedCountries: [ "FR", "GB", "DE" ]
}));
When Countries Whitelist is uses you restict access to the application only for the IPs assigned to the countries in the whitelist. The Country Code MUST be upper case ISO 3166-2 Code.
You can specify only countries blacklist or whitelist. You cannot use both at the same time. But you can use IPs blacklist and countries blacklist or whitelist.
var ipgeoblock = require("node-ipgeoblock");
var app = express();
app.use(ipgeoblock({
geolite2: "./GeoLite2-Country.mmdb",
blocked: ["192.168.0.1", "192.168.0.3", "192.168.0.4"],
blockedCountries: [ "FR", "GB", "DE" ]
}));
Node-ipgeoblock adds IP country information to the request object.
app.use(function (req, res) {
// MaxMind GeoLite2 country object
console.log(JSON.stringify(req.location.country.data));
// Country ISO 3166-2 code
console.log(req.location.country.isoCode);
});
var ipgeoblock = require("node-ipgeoblock");
var app = express();
app.use(ipgeoblock({
geolite2: "./GeoLite2-Country.mmdb",
blocked: ["192.168.0.1", "192.168.0.3", "192.168.0.4"]
}, function (req, res) {
res.statusCode = 500;
res.end("Internal Server Error");
}));
FAQs
Middleware to allow or block requests based on origin country.
We found that ipgeoblock-fixed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.