Alternatives to http-proxy
@williamstein đang làm issue này rồi.
Từ ngày 7/5/2025.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- express, javascript, node.js
- Lĩnh vực
- backend
Hướng nghiên cứu
Issue không nêu tệp repository, test hoặc entry point nào. Hãy bắt đầu bằng việc xem xét các ví dụ proxy Node.js được liệt kê và xác định liệu maintainer muốn một tài liệu về các lựa chọn thay thế hay một thay đổi khác; công việc chỉ được xem là hoàn tất khi phạm vi đã được thống nhất và đã có quyết định về nơi đặt tài liệu đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I've been using this module for a long time for http proxying, but since it's no longer maintained i was looking into alternatives.
For what it's worth, sharing my findings here.
Using node basic modules
My usecase: i have a expressjs app for which i want to proxy all requests to a Node process running on the same machine, on a different port. This code snippet shows how to proxy request/response including error handling.
const stream = require('stream');
const util = require('util');
const pipeline = util.promisify(stream.pipeline);
// proxyPort, req and res are passed here
// proxyPort: 5000
// req: incoming expressjs request
// res: outgoing expressjs response
// custom agent if needed
const proxyAgent = new http.Agent({
keepAlive: global.PROXY_CONFIG.useKeepAlive,
maxSockets: global.PROXY_CONFIG.maxSockets
});
// copy over url, method and headers here
const requestOptions = {
hostname: "localhost",
port: proxyPort,
path: req.url,
method: req.method,
agent: proxyAgent ,
headers: req.headers
};
// create the proxy request
const proxyReq = http.request(requestOptions, async (proxyRes) => {
// Proxy response headers
for (const headerName of Object.keys(proxyRes.headers)) {
res.setHeader(headerName, proxyRes.headers[headerName]);
}
// Proxy response status code and message
res.statusCode = proxyRes.statusCode;
res.statusMessage = proxyRes.statusMessage;
// send the response body of the proxied response to the origin response
try {
await pipeline(proxyRes, res);
} catch (err) {
// add error handling here or log it at least
res.send(500).end();
} finally {
// proxy is done here, log it?
}
});
// Proxy the request body
try {
await pipeline(req, proxyReq);
} catch (error) {
// add error handling here or log it at least
res.send(500).end();
} finally {
// The request body is fully proxied here, if you want to do anything with this information
}
This snippet doesn't offer everything this module offers, but it's easily extendable to add features like adding/removing headers from the request or response. It's all plain node code, no additional module involved.
Other proxy modules or ways to do it
- https://github.com/TooTallNate/proxy-agents/tree/main/packages/http-proxy-agent / https://github.com/TooTallNate/proxy-agents/tree/main/packages/https-proxy-agent
- https://medium.com/@glorywong1001/nodejs-http-s-proxy-0abd718b506a
I hope this is helpful to others moving away from http-proxy.
- Ngôn ngữ chính
- JavaScript
- Star
- 14.1k
- Fork
- 2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của http-party/node-http-proxy
-
util._extend() is depracatoryĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
http-party/node-http-proxy#1719 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
http-party/node-http-proxy#1721 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 55/100
http-party/node-http-proxy#1715 · 1 bình luận · 5 reaction ·
-
Is this library is dead?Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 15/100
http-party/node-http-proxy#1711 · 2 bình luận ·
-
HTTP3 + QUIC support?Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
http-party/node-http-proxy#1710 · 5 reaction ·
Tất cả issue của http-party/node-http-proxy
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
guybedford/es-module-lexer#266 ·
-
bug documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
apify/apify-docs#3206 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
anhnt256/cursor-swarm#21 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
zerohourzulu/irontrellis#16 ·