Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.
/ therealyou Public archive

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

License

Notifications You must be signed in to change notification settings

briandela/therealyou

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published