Git Product home page Git Product logo

cloudflare-ips's Introduction

CloudFlare IP Ranges

build status npm version npm downloads

The list of CloudFlare IPs (IP ranges) to be used in the trust proxy configurations.

How to Use

$ npm install cloudflare-ips    # or, `yarn add cloudflare-ips`
const express = require('express');
const cloudflareIPs = require('cloudflare-ips');

const app = express();

cloudflareIPs(
  ips => app.set('trust proxy', ['loopback', ...ips]),
  err => console.error(err.stack),
);

cloudflareIPs((err, ips) => {
  app.set('trust proxy', ['loopback', ...ips]);
});

app.listen(8080);

API

cloudFlareIPs(onUpdate, onError, options)

  • onUpdate: (ips: string[]) => void — a callback function accepting the list of IPs
  • onError: (err: Error) => void — a callback that is triggered on error (optional)
  • options: { inteval: number } — allows to tweak the default settings (optional)

Related Projects

License

Copyright © 2017-present Kriasoft. This source code is licensed under the MIT license found in the LICENSE.txt file.


Made with ♥ by Konstantin Tarkus (@koistya, blog)

cloudflare-ips's People

Contributors

koistya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cloudflare-ips's Issues

ips is undefined

Using the second example from the docs throws the error
TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined`

cloudflareIPs((err, ips) => {
  app.set('trust proxy', ['loopback', ...ips]);
});

The callback with 2 params doesn't work as there is no err passed. I think easiest solution is to just remove this callback style from the docs.

Fix: remove err from the callback.

cloudflareIPs((ips) => {
  app.set('trust proxy', ['loopback', ...ips]);
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.