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.
npm install bluemix-cf-ip-filter
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'))
}
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'))
}
Tested using mocha, chai and sinon
npm test