0

我正在尝试让 node-http-proxy 与 AppJS 一起工作。不幸的是,它在启动应用程序时崩溃。我做了什么:

  • 从http://appjs.com/下载并提取 AppJS ;
  • 使用 npm install http-proxy 安装 node-http-proxy;
  • 编辑了 app.js window.on(create) 函数:

    window.on('create', function(){
    console.log("Window Created");
    window.frame.show();
    window.frame.center();
    window.frame.setMenuBar(menubar);
    
    var http = require('http'),
    httpProxy = require('http-proxy');
    // 
    // Create your proxy server and set the target in the options. 
    // 
    httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000);
    
    // 
    // Create your target server 
    // 
    http.createServer(function (req, res) {
      res.writeHead(200, { 'Content-Type': 'text/plain' });
      res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
      res.end();
    }).listen(9000);
    });
    

当应用程序启动时,我想启动 nodeJS 代理服务器。是否可以从外部 PC 连接到此代理服务器?(我知道我需要为此打开端口)

例如,如果我在家用 PC 上运行该应用程序并且在工作中,我会将工作 PC 的代理设置设置为 homePC_IP:8000。这行得通吗?

4

1 回答 1

0

还没有解决 node-http-proxy 崩溃的问题,但我使用了https://github.com/TooTallNate/proxy,这就像一个魅力!

于 2015-05-12T16:02:39.513 回答