node-test/app.js

26 lines
616 B
JavaScript

const express = require('express');
const PORT = 8900;
const HOST = '0.0.0.0';
const instanceNumber = Math.floor(Math.random() * 101);
const app = express();
app.get('/', (req, res) => {
var xFwdIp = req.headers['x-forwarded-for'];
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, () => {
console.log(`Server started on http://${HOST}:${PORT}`);
});