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.
Requires node 8
or newer.
npm install --save cloudfront-ip-ranges
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.
const cfIPranges = require('cloudfront-ip-ranges')
cfIPranges.updateTrustProxy(app)
setInterval(() => {
cfIPranges.updateTrustProxy(app)
}, 1000*60*60*12)
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])
})
Method | Info |
---|---|
getIpRange | By default returns Promise<string[]> . |
updateTrustProxy | Takes an Express app instance as an argument. Returns Promise<void> . |
Version | Release notes |
---|---|
0.1.2 | Dependency updates |
0.1.1 | Added local IP to trust proxy |
0.1.0 | Initial release. |