change the ipfiltering to be based on x-forwarded for
This commit is contained in:
parent
78761eb37e
commit
30914719aa
1 changed files with 14 additions and 2 deletions
|
|
@ -51,8 +51,20 @@ app.get('/headers', function (req, res) {
|
|||
console.log(req.headers);
|
||||
res.status(200).send('success');
|
||||
});
|
||||
//restrict access to anything else via ip addresses
|
||||
//if (config.ipfilter.allowed_ips.length > 0) app.use(ipfilter(config.ipfilter.allowed_ips, { mode: 'allow' }))
|
||||
//restrict access to anything else via ip addresses based on x-forwarded for
|
||||
let clientIp = function(req, res) {
|
||||
return req.headers['x-forwarded-for'] ? (req.headers['x-forwarded-for']).split(',')[0] : ""
|
||||
};
|
||||
|
||||
if(config.ipfilter.allowed_ips.length > 0){
|
||||
app.use(
|
||||
ipFilter({
|
||||
detectIp: clientIp,
|
||||
forbidden: 'You are not authorized to access this page.',
|
||||
filter: allowlist_ips,
|
||||
})
|
||||
);
|
||||
}
|
||||
if (config.accesslog) app.use(logger('common'));
|
||||
app.disable('x-powered-by');
|
||||
app.use(favicon(path.join(publicPath, 'favicon.ico')));
|
||||
|
|
|
|||
Loading…
Reference in a new issue