我正在开发bots对于 telegram ,我来自伊朗,telegram url 在我的国家被屏蔽,我被迫使用 VPN/代理服务器从我的本地开发机器访问 telegram api。
但是我的系统上运行着其他应用程序,这些应用程序无法使用 VPN,所以我被迫使用 proxifier ,我可以为需要抛出代理的应用程序定义规则。
但是node.exe由于某种原因忽略了这个规则,我可以在NetLimiter中看到连接来自 C:\Program Files (x86)\nodejs\node.exe
,但是将此路径添加到 proxifier 的规则中没有效果,其他应用程序(例如 telegram 本身和 firefox 等)...符合这些规则可以很好地工作......
那么有人设法强制 node.exe 抛出 proxifier 吗?
我还尝试在我的主机中使用 php 设置代理,但我发现的代理脚本都无法处理文件上传
我最后的希望是为apache安装一些模块并将其用作代理或只安装nginx ...
我也尝试过https://github.com/krisives/proxysocket和 https://github.com/TooTallNate/node-https-proxy-agent没有成功,它只是不断抛出错误:(
最佳答案
好的,经过几个小时的尝试,终于让它可以与 proxifier 一起使用了。
https://github.com/TooTallNate/node-https-proxy-agent
new HttpsProxyAgent('http://用户名:密码@127.0.0.1:8080')
更新: 这种方法有其问题,因此我使用node-http-proxy创建了一个小型个人代理服务器。在我的服务器上并连接到它:
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
const debug = require('debug')('app');
const http = require('http');
const httpProxy = require('http-proxy');
const proxy = httpProxy.createProxyServer({
secure : false
});
proxy.on('error', function (e) {
debug(e);
});
const server = http.createServer(function(req, res) {
// You can define here your custom logic to handle the request
// and then proxy the request.
proxy.web(req, res, { target: 'https://api.telegram.org', });
});
server.listen(3333);
并且只是将所有请求重定向到此服务器。
关于node.js - 强制 node.exe 在 Windows 10 上抛出 proxifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53388801/