hapi.js plugin for setting the request.info.remoteAddress and request.info.remotePort based on the X-Forwarded-For and X-Forwarded-Port headers
Switch branches/tags
Nothing to show
Clone or download
forbi and briandela Update to Hapi v17. (#8)
* Update to Hapi 17

* Update Ussage in README

* test coverage hapi 17

* test coverage hapi 17

* update package.json

* Travis for Hapi 17.

node >= 8

* fix typo in test unit
Latest commit be6d855 Jan 9, 2018
Permalink
Failed to load latest commit information.
lib
test Update to Hapi v17. (#8) Jan 10, 2018
.eslintrc Update to Hapi v17. (#8) Jan 10, 2018
.gitignore Initial commit Jan 15, 2016
.travis.yml Update to Hapi v17. (#8) Jan 10, 2018
LICENSE Initial commit Jan 15, 2016
README.md Update to Hapi v17. (#8) Jan 10, 2018
package.json Update to Hapi v17. (#8) Jan 10, 2018

README.md

therealyou

Build Status Coverage Status npm version Dependencies Up To Date

hapi.js plugin for setting the request.info.remoteAddress and request.info.remotePort based on the X-Forwarded-For and X-Forwarded-Port headers

X-Forwarded-For

see: https://en.wikipedia.org/wiki/X-Forwarded-For

The general format of the x-forwarded-for header is:

X-Forwarded-For: client, proxy1, proxy2

This plugin sets request.info.remoteAddress to the first value of the x-forwarded-for header if it is set.

For example, if the header was

'x-forwarded-for': '192.16.184.5, 192.16.184.6, 192.16.184.2'

then remote.info.remoteAddress would be set to 192.16.184.5

X-Forwarded-Port

This plugin sets request.info.remotePort to the value of the x-forwarded-port header

Usage

const Hapi = require("hapi"); 
 
const server = new Hapi.Server({   
  host: 'localhost', 
  port: 3000 
}) 
 
 
server.register({ 
  plugin: require('./lib') 
}).then(_=>{ 
  server.start(function() { 
      console.log("up"); 
    }); 
}) 

License

MIT