bluemix-cf-ip-filter
v0.1.3
Published
Express middleware for applying IP filtering
Downloads
3
Maintainers
Readme
Bluemix CF IP Filter
Express middleware for IP Based Filtering of incoming requests to Bluemix cloudfoundry apps. The standard IP filtering middleware wont work here as bluemix will proxy your request, use this if your hosting in bluemix instead.
Cloudfoundry on Bluemix does not support restricting allowed IPs in its configuration, you can easily add this functionality to your existing express application using this module.
Installation
npm install bluemix-cf-ip-filter
Usage
Allowed Mode (Default)
The middleware will allow requests originating from listed address and respond with standard 403 response any to others.
const ipFilter = require('bluemix-cf-ip-filter')
const express = require('express')
const app = express()
if(process.env.NODE_ENV === 'production') {
// allowed mode only listed ips will connect
app.use(ipFilter(['22.223.1.24'], 'allow'))
}
Banned mode
middleware will block requests originating from listed address with a 403 response and allow unlisted IPs.
if(process.env.NODE_ENV === 'production') {
// listed ips will be blocked
app.use(ipFilter(['22.223.1.24'], 'block'))
}
Tests
Tested using mocha, chai and sinon
npm test