2.1.0 • Published 6 years ago

walk8243-proxy v2.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

walk8243-proxy

一つのサーバ内で複数のNodeサーバを立ち上げるためのプロキシサーバを作成

GETTING STARTED

git cloneの場合

/data/proxy.config.ymlの内容を任意に書き換えて以下のコマンドを実行してください。 書き換えはこのモジュールの Options を参考にしてください。 差異は、proxyType のみです。

# root権限を持っていない場合
sudo npm start

# root権限を持ってる場合
npm start

npm installの場合

const http = require('http'),
      proxy = require('walk8243-http-proxy');
const proxys = proxy.generateProxyConfig({
  'fuga.hoge': {
    proxyType: 'redirect',
    Location: 'www.fuga.hoge'
  },
  'www.fuga.hoge': {
    proxyType: reverseProxy,
    target: {
      host: 'localhost',
      port: 8080,
    }
  }
});

http
  .createServer((req, res) => {
    if(!proxys.hasOwnProperty(req.headers.host)) return res.sendStatus(404);
    proxy.httpProxyServer(req, res, proxys)
  }).listen(80);

LICENSE

walk8243-proxy is released under the ISC LICENSE