我正在使用节点js和angular ui创建一个应用程序,我需要ping服务器。 为了ping服务器,我编写了以下代码,完美无缺:
app.get("/api/getPing", function (req, res) {
var target = req.query.target;
var hosts = [target];
hosts.forEach(function (host) {
ping.sys.probe(host, function (isAlive) {
if (isAlive) {
res.send(true);
}
else {
res.send(false);
}
});
});
});
但是我无法ping几台需要代理设置的服务器。有人可以告诉我如何使用我的应用程序设置代理。
提前致谢
答案 0 :(得分:0)
您可以使用 express-http-proxy
var proxy = require('express-http-proxy');
app.use('/proxy', proxy('www.google.com'));