Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

cloudfront-ip-ranges

0.1.2 • Public • Published

Cloudfront IP ranges

npm npm Dependents (via libraries.io) semantic-release

Get Cloudfront IPs for use in trust proxy configurations.

This package will be updated if Cloudfront ever decides to change the endpoints for retrieving current IPs. We will most likely never see a breaking change for this package.


Install

Requires node 8 or newer.

npm install --save cloudfront-ip-ranges

Usage

For use in an Express environment please see Express documentation on trust proxies.

It is recommended to use setInterval for updating the IP list periodically.

Directly update trust proxies for an Express app

const cfIPranges = require('cloudfront-ip-ranges')

cfIPranges.updateTrustProxy(app)

setInterval(() => {
  cfIPranges.updateTrustProxy(app)
}, 1000*60*60*12)

Getting a list of IPs and updating trust proxies manually

Useful if you need to list other proxies alongside the Cloudfront ones.

const cfIPranges = require('cloudfront-ip-ranges')

cfIPranges.updateIPs()
  .then((ips) => {
    app.set('trust proxy', ['loopback', ...ips])
  })

API

Method Info
getIpRange By default returns Promise<string[]>.
updateTrustProxy Takes an Express app instance as an argument. Returns Promise<void>.

Changelog

Version Release notes
0.1.2 Dependency updates
0.1.1 Added local IP to trust proxy
0.1.0 Initial release.

Install

npm i cloudfront-ip-ranges

DownloadsWeekly Downloads

190

Version

0.1.2

License

MIT

Unpacked Size

151 kB

Total Files

18

Last publish

Collaborators

  • avatar