express-real-ip
v1.0.0
Published
Use X-Real-Ip header for req.ip in express
Downloads
253
Maintainers
Readme
express-real-ip
Get ip address from custom header
var app = require('express')();
var getRealIp = require('express-real-ip')();
app.use(getRealIp);
app.get('/', function (req, res, next) {
res.send(req.ip);
next();
});
app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
// curl localhost:3000 -H "X-Real-Ip: 87.250.248.98"
// 87.250.248.98
API
express-real-ip([options])
Returns middleware function, that appends header value to X-Forwarded-For header (this is how express figures out req.ip
value).
options
headerName
- name of header, which contains real ip address (defaults toX-Real-Ip
).
License
MIT (c) 2014 Vsevolod Strukchinsky ([email protected])