Closed c0debreaker closed 6 years ago
TBH. Never tried it.
You could try these npm packages: https://www.npmjs.com/package/socks5-https-client https://www.npmjs.com/package/socks5-http-client
And configure the proxy agent
similar to:
https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/corporate-proxy.md
Basically provide a socksv5
compatible agent as config.
Let me know if this works or not.
Cool. I'll let you know. Thanks!
Hi chimurai. We enabled http proxy and it's working now. :)
I have a question though. Since this configuration is proxy-agent or as client, what does the target
property really do especially the agent is already pointing to a proxy server?
var options = {
target: 'http://localhost:3000',
agent: new HttpsProxyAgent('http://internal-squid-svr:3128')
};
var apiProxy = proxy('/api', options);
Glad to hear you've found a working setup.
Mind sharing which npm module you used for HttpsProxyAgent
?
You can see target
as application logic. i.e. proxy /api
request to this target
.
How the actual requests/connection are handled is determined by agent
https://nodejs.org/dist/latest-v9.x/docs/api/http.html#http_class_http_agent
These requests can be configured to go through another proxy as well...
The npm proxy module is the one from the link you sent above, http-proxy-agent. :)
Another question. When my request is https, I don't see the traffic goes to our proxy. What could be wrong in my setup? I'm using the same configuration from https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/corporate-proxy.md
Here is my setup. On my laptop, I'm running http-proxy-middle-ware and http-proxy-agent. Let's say our http proxy is 192.168.1.1:2301
var proxyConfig = proxy({
agent: new HttpsProxyAgent('http://192.168.1.1:2301'),
target: 'http://website-A.example.com'
});
app.use('/', proxyConfig);
However, I also need to reach https://website-B.example.com
and this is the one that I cannot reach. However, if I configure my browser's network proxy setting pointing to http://192.168.1.1:2301, I can reach https://website-B.example.com
. What could be missing on my code?
can target:
be an array like this. Is this possible?
var proxyConfig = proxy({
agent: new HttpsProxyAgent('http://192.168.1.1:2301'),
target: ['http://website-A.example.com', 'http://website-B.example.com']
});
app.use('/', proxyConfig);
I got it working :)
I created two entries
app.use('/app/path', proxyHttpConfig);
app.use('/app/another/path', proxyHttpsConfig); // <- this is working now :)
app.use('/', proxyHttpConfig);
Is it possible?