提交 60c97e6f 编写于 作者: Q qq_41923622

Mon Feb 10 20:25:00 CST 2025 inscode

上级 8d352378
......@@ -2,18 +2,25 @@ const http = require('http');
const httpProxy = require('http-proxy');
// 创建代理服务器实例
const proxy = httpProxy.createProxyServer({
target: 'https://s.hunlihu.com', // 替换为你要代理的目标服务器地址
// target: 'https://s.hunlihu.com', // 替换为你要代理的目标服务器地址
changeOrigin: true,// 改变源地址,使目标服务器能正确识别请求来源
autoRewrite: true,
protocolRewrite: 'http',
// protocolRewrite: 'http',
});
// 定义子目录和对应的目标服务器映射
const subdirectoryMappings = {
'shunlihu': 'https://s.hunlihu.com',
};
// 创建HTTP服务器
const server = http.createServer((req, res) => {
// proxyRes.headers =
console.log(11,req.url, req.headers)
req.headers['origin'] = "https://s.hunlihu.com";
req.headers['referer'] = "https://s.hunlihu.com";
console.log(112, req.headers)
proxy.options.target=subdirectoryMappings.shunlihu;
req.headers['origin'] = subdirectoryMappings.shunlihu;
req.headers['referer'] = subdirectoryMappings.shunlihu;
req.headers['host'] = "h5.hunlihu.com";
req.url = req.url.replace(new RegExp(`^\/shunlihu`), '');
console.log(11,req.url, req.headers)
// 将请求代理到目标服务器
proxy.web(req, res);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册