print CF-Connecting-IP/X-Forwarded-For when present

This commit is contained in:
Nick Krecklow 2020-04-01 21:48:37 -05:00
parent cf8f3f0dcd
commit 1382a6a21e
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94

View File

@ -27,7 +27,12 @@ function setupRoutes() {
function handleRequest(req, res) {
var requestUrl = url.parse(req.url).pathname;
logger.log('info', '%s requested: %s', req.connection.remoteAddress, requestUrl);
let remoteAddress = req.connection.remoteAddress;
if (req.headers && (req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'])) {
remoteAddress = req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'];
}
logger.log('info', '%s requested: %s', remoteAddress, requestUrl);
if (requestUrl === '/publicConfig.json') {
res.setHeader('Content-Type', 'application/javascript');