LoginSignup
16
14

More than 5 years have passed since last update.

node.jsでポートフォワーディング

Last updated at Posted at 2012-11-21

http-proxyモジュールのインストール

npm install http-proxy 
port_forwarding.js
var httpProxy = require('http-proxy');
var options = {
    hostnameOnly:true,
    router: {
        'example.com': '127.0.0.1:8080',
        'hoge.example.com': '127.0.0.1:9090'
    }

}
httpProxy.createServer(options).listen(80);

80番ポートをlistenして、example.comにアクセスしてきた通信を8080ポートに、hoge.example.comでアクセスしてきた通信を9090ポートに送る。

node.jsでTCPプロキシ&ポートフォワーディング

16
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14