Intercept websocket request before proxying it to server via http-proxy
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 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 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 个 reaction ·
-
难度 1/5 1 小时以内 新手友好度 15/100
http-party/node-http-proxy#1711 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
http-party/node-http-proxy#1710 · 5 个 reaction ·
查看 http-party/node-http-proxy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
guybedford/es-module-lexer#266 ·
-
bug documentation
难度 1/5 1-3 小时 新手友好度 88/100
apify/apify-docs#3206 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 90/100
anhnt256/cursor-swarm#21 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 74/100
zerohourzulu/irontrellis#16 ·