设为首页 加入收藏

TOP

【nodejs代理服务器一】nodejs http-proxy 开发反向代理服务器,防火墙,过滤常见的web渗透(二)
2019-09-17 19:09:00 】 浏览:58
Tags:nodejs 代理 服务器 http-proxy 开发 防火墙 过滤 常见 web 渗透
ram url * @returns {*} */ function urlHandler(url) { var tempUrl = url.substring(url.lastIndexOf("/")); return proxyPassConfig[tempUrl]; } function invalidHandler(res) { res.writeHead(400, {'Content-Type': 'text/plain'}); res.write('Bad Request '); res.end(); } function noPattern(res) { res.writeHead(404, {'Content-Type': 'text/plain'}); res.write('not found'); res.end(); } function getClientIp(req){ return req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress; } function appendLog(req) { console.log("request url:" + req.url); var logData = (new Date()).Format("yyyy-MM-dd hh:mm:ss")+" "+getClientIp(req)+" "+req.method+ " "+req.url+"\n"; fs.exists(logRootPath,function(exists){ if(!exists){ fs.mkdirSync(logRootPath) } fs.appendFile(getCurrentDayFile(),logData,'utf8',function(err){ if(err) { console.log(err); } }); }) } console.log("listening on port 80".green.bold) server.listen(80);

思路扩展

  • 拦截非法字符后可以发邮件通知管理员
  • 可以把日志发送到日志系统,进行大数据分析
  • 增加频繁访问,拒绝Ip功能。 可以利用redis 过期缓存实现。
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇理解原型和原型链 下一篇vue 父组件中调用子组件函数

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目