【发布时间】:2018-04-09 19:56:55
【问题描述】:
所以我使用localtunnel 在互联网上公开我的端口,但我只想让与服务器位于同一网络上的设备访问服务器。
我正在使用express-ip-filter 过滤掉其他网络上的任何内容。我尝试了一些事情:首先我尝试使用 192.168.1.0/24 作为唯一可以访问该网站的 ip,但这不起作用,因为它没有让任何东西进入。然后我尝试使用从 WhatsMyIp 获得的 ip,但这不会让任何设备进入。然后我发现express-ip-filter 吐出一条消息说不允许某个 ip 并且在每台设备上,独立于它所连接的网络上,地址是 @987654325 @。我尝试通过只允许127.0.0.1 进行确认,然后每个设备都可以访问服务器。为什么 ip-filter 只能获取 127.0.0.1 作为 ip?这是我的代码作为参考:
// Init dependencies
var express = require('express'),
ipfilter = require('express-ipfilter').IpFilter
app = express()
// Blacklist the following IPs
var ips = ['192.168.1.0/24']
// Create the server
app.use(ipfilter(ips, { mode: "allow" }))
app.get('/', function (req, res) {
res.send('Hi')
})
app.listen(8080, () => console.log('Up'))
【问题讨论】:
标签: javascript node.js express ip localtunnel