Offer several IP Get Methods
This commit is contained in:
parent
deb078980b
commit
c15455e0d0
13
app.js
13
app.js
@ -8,8 +8,17 @@ const instanceNumber = Math.floor(Math.random() * 101);
|
|||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
var ip = req.headers['x-forwarded-for'] || req.ip;
|
var xFwdIp = req.headers['x-forwarded-for'];
|
||||||
res.send(`node-test instance ${instanceNumber}, your IP: ${ip}`);
|
var xRealIp = req.headers['x-real-ip'];
|
||||||
|
res.send(
|
||||||
|
{
|
||||||
|
instanceId: instanceNumber,
|
||||||
|
xForwardedFor: xFwdIp,
|
||||||
|
xRealIp: xRealIp,
|
||||||
|
requestIp: req.ip,
|
||||||
|
requestTime: Math.floor(Date.now() / 1000)
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(PORT, HOST, () => {
|
app.listen(PORT, HOST, () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user