首页 > 解决方案 > 如何创建本地 https 代理

问题描述

我正在尝试制作一个我将在本地托管的 http 和 https 代理。服务器的目标是在我的浏览器中使用它。我将https://npmjs.com/http-proxy用于 HTTP 请求,代码如下:

app.use("/", (req, res) => {
    logger.info(
        "[HTTP] " +
            chalk.blueBright(">> ") +
            req.hostname +
            chalk.grey(" : ") +
            req.path +
            chalk.grey(" : ") +
            req.headers["user-agent"]
    );

    httpProxy.web(req, res, { target: req.url, hostRewrite: true });
});

当我跑步时效果很好curl -x localhost:7540 http://wtfismyip.com/headers,但是当我跑步时curl -x localhost:7540 https://wtfismyip.com/headers,我得到了curl: (56) Proxy CONNECT aborted

标签: node.jsexpresshttpproxy

解决方案


推荐阅读