Intercept websocket request before proxying it to server via http-proxy
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 20/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
- 領域
- backend, networking
調査の方向性
まず、issue に示されている server.on('upgrade')、proxy.ws()、および proxyReqWs イベント周辺の websocket フローを読み、その後 REST-proxyReq フローと比較します。完了条件は、接続をプロキシして選択されたインスタンスへルーティングする前に、websocket 認証データへアクセスするための明確で文書化された手順が得られることです。
索引モデルが issue の本文から書いたものです。
説明
Here is my code for proxying the websocket request to the targer server. What I want to achieve is that like in case of REST requests in http-proxy, we use proxyReq event to modify the request if we want by accessing headers and req.body, I want to do the same for weboscket request as I want to access the authentication data auth that is passed from the socket client. I don't want to log or intercept the traffic sent or received after the weboscket connection, instead I want to intercept (not modify though) the actual request that contains data to authenticate the client on proxyReqws event or on upgrade event of server. Any help & guidance would be appreciated.
var app = express();
const fs = require('fs')
var https = require('https')
var httpProxy = require('http-proxy');
const credentials = { key: fs.readFileSync("localhost.key"), cert: fs.readFileSync("localhost.cert") };
var proxy = httpProxy.createProxyServer({ ws: true });
var server = https.createServer(credentials, app).listen(8080)
proxy.on('proxyReqWs', (proxyReq, req, socket, options, head) => {
//before the request is actually proxyed to the target server
//access websocket request & modify it
});
app.use('/socket.io', function (req, res) {
proxy.on('proxyRes', function (proxyRes, req, res) {
//on response, do something
});
proxy.on('error', function (err, req, res) {
console.log(err)
})
proxy.web(req, res, { target: { host: address.host, port: address.port, path: '/socket.io' } })
})
server.on('upgrade', function (req, socket, head) {
console.log("Upgraded to websockets")
proxy.ws(req, socket, head, { target: { host: address.host, port: address.port, path: '/socket.io' } });
});
On the basis of information I get from auth, the request will be routed to the specific instance.
- 主要言語
- JavaScript
- スター
- 14.1k
- フォーク
- 2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
http-party/node-http-proxy のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
http-party/node-http-proxy#1719 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
http-party/node-http-proxy#1721 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
http-party/node-http-proxy#1715 · コメント 1 件 · リアクション 5 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 15/100
http-party/node-http-proxy#1711 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
http-party/node-http-proxy#1710 · リアクション 5 件 ·
http-party/node-http-proxy の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/TypeScript#65370 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TMHSDigital/Free-Game-Dev-Assets#272 ·
メンテナーはふだん 1 日以内に返信
-
metrics priority: medium
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
LearningCircuit/local-deep-research#8336 ·
メンテナーはふだん 1 日以内に返信
-
ace bug yaml
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
svelte: whitespace-only edit leaves an empty todo, edits not trimmed, filter not restored on reloadオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100