Socket
Socket
Sign inDemoInstall

mod_cloudflare

Package Overview
Dependencies
9
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mod_cloudflare

Inspired by mod_cloudflare.c, this ExpressJS middleware will replace the IP variable with the correct remote IP sent from CloudFlare.


Version published
Maintainers
1
Install size
573 kB
Created

Readme

Source

mod_cloudflare

Based on mod_cloudflare.c, this ExpressJS middleware will replace the IP variable with the correct remote IP sent from CloudFlare.

To install, simple run:

npm install mod_cloudflare --save

Usage

const express = require('express')
const app = express()

const mod_cloudflare = require('mod_cloudflare');

app.use(mod_cloudflare());

app.get('/', function (req, res) {
  res.send(`Your IP is: {$req.ip}`);
})

app.listen(3000);

Options

By default mod_cloudflare will still accept non-cloudflare connections. This can be changed by passing an object with the desired options to the mod_cloudflare constructor.

OptionDefault SettingDescription
CloudFlareRemoteIPHeader"CF-Connecting-IP"The header which contains the original IP.
DenyAllButCloudflarefalseDeny all requests that aren't sent via CloudFlare.
CloudFlareRemoteIPTrustedProxy[ ]Additional array of IP addresses or ranges which are to be treated as CloudFlare IPs.
ForbiddenPagenullOnly served to denied clients. The path to serve as 403 FORBIDDEN page.

Keywords

FAQs

Last updated on 07 Jun 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc