如何在Node.js HTTP服务器应用程序中通过IP地址限制访问?
我正在寻找这样的东西:
Deny from all Allow from ..
我只需要允许访问该站点的几个IP地址。我怎样才能做到这一点?
我不确定这种方法的安全性,但这里是从网上答案中收集的:
var http = require('http'); http.createServer(function (req, res) { var ip = req.ip || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress; if (ip == '127.0.0.1') // exit if it's a particular ip res.end(); ...
请,一个更精通节点的人-纠正我