Skip to content

Express middleware to restrict server access using IP addresses for node apps on Bluemix Cloudfoundry

License

Notifications You must be signed in to change notification settings

Astr-o/bluemix-cf-ip-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Express middleware to restrict server access using IP addresses for node apps on Bluemix Cloudfoundry

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published