Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theevilsocks/mod_cloudflare
https://github.com/theevilsocks/mod_cloudflare
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/theevilsocks/mod_cloudflare
- Owner: TheEvilSocks
- License: apache-2.0
- Created: 2019-01-28T21:23:19.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-07T21:10:25.000Z (over 4 years ago)
- Last Synced: 2024-11-19T21:45:25.777Z (about 2 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## 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 ###
```javascript
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.
Option | Default Setting | Description
------------ | ------------- | -------------
CloudFlareRemoteIPHeader | `"CF-Connecting-IP"` | The header which contains the original IP.
DenyAllButCloudflare | `false` | Deny all requests that aren't sent via CloudFlare.
CloudFlareRemoteIPTrustedProxy | `[ ]` | Additional array of IP addresses or ranges which are to be treated as CloudFlare IPs.
ForbiddenPage | `null` | Only served to denied clients. The path to serve as 403 FORBIDDEN page.