Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendrucker/req-ip
Middleware for appending req.ip to HTTP requests with support for reverse proxies
https://github.com/bendrucker/req-ip
Last synced: 3 days ago
JSON representation
Middleware for appending req.ip to HTTP requests with support for reverse proxies
- Host: GitHub
- URL: https://github.com/bendrucker/req-ip
- Owner: bendrucker
- License: mit
- Created: 2016-08-17T15:33:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T23:37:10.000Z (about 5 years ago)
- Last Synced: 2024-09-22T10:03:42.248Z (6 days ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# req-ip [![Build Status](https://travis-ci.org/bendrucker/req-ip.svg?branch=master)](https://travis-ci.org/bendrucker/req-ip) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/req-ip.svg)](https://greenkeeper.io/)
> Middleware for appending `req.ip` to HTTP requests with support for reverse proxies
## Install
```
$ npm install --save req-ip
```## Usage
```js
var ReqIp = require('req-ip')
var reqIp = ReqIp()reqIp(req, res, function (err) {
//=> req.ip === '1.2.3.4'
})
```## API
#### `ReqIp(header)` -> `function`
Returns a middleware function that applies `req.ip` and then calls back.
##### header
Type: `string`
Default: `'x-forwarded-for'`A header name to use to set the IP address. When no matching header is found, `req.connection.remoteAddress` is used instead.
## License
MIT © [Ben Drucker](http://bendrucker.me)