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: 4 months 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 (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T23:37:10.000Z (almost 6 years ago)
- Last Synced: 2025-03-24T01:49:53.164Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# req-ip [](https://travis-ci.org/bendrucker/req-ip) [](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)