Skip to content

Middleware for Koa2 that allows to trust specified reverse proxies while distrusting another

Notifications You must be signed in to change notification settings

SagePtr/koa-trust-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

koa-trust-proxy

Middleware for Koa2 that allows to trust specified proxies while distrusting another

Replaces app.proxy = true

Installation

$ npm install koa-trust-proxy

Examples

const Koa = require('koa');
const trustProxy = require('koa-trust-proxy');

const app = new Koa();

// This line is not needed
//app.proxy = true

// Use middleware instead
// 1st parameter is array or comma-separated list of trusted proxies, default ['127.0.0.1/8', '::1/128']
// 2nd parameter is trusted header, default is X-Forwarded-For
app.use(trustProxy('127.0.0.1, ::1', 'X-Real-IP'));
// You can use CIDRs as well
app.use(trustProxy('192.168.0.1/24, ::1/128', 'X-Real-IP'));

..........

Aliases

This module also supports well-known aliases:

  • loopback: 127.0.0.1/8, ::1/128,
  • linklocal: 169.254.0.0/16, fe80::/10
  • uniquelocal: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7

License

MIT

About

Middleware for Koa2 that allows to trust specified reverse proxies while distrusting another

Resources

Stars

Watchers

Forks

Packages

No packages published