bluemix-cf-ip-filter

0.1.3 • Public • Published

Bluemix CF IP Filter

npm version Build Status Coverage Status dependencies Status

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

Package Sidebar

Install

npm i bluemix-cf-ip-filter

Weekly Downloads

0

Version

0.1.3

License

MIT

Last publish

Collaborators

  • astr-o