GithubHelp home page GithubHelp logo

tootallnate / proxy-agents Goto Github PK

View Code? Open in Web Editor NEW
872.0 872.0 229.0 838 KB

Node.js HTTP Proxy Agents Monorepo

Home Page: https://proxy-agents.n8.io

JavaScript 4.99% TypeScript 95.01%
agent http https nodejs pac proxy socks

proxy-agents's Introduction

Node.js HTTP Proxy Agents Monorepo

Build Status

This monorepo contains various Node.js HTTP Agent implementations that operate over proxies using various protocols.

For the most common use-cases, you should be using the proxy-agent module, which utilizes the other, more low-level, agent implementations.

You can find changelogs here.

proxy-agents's People

Contributors

byjrack avatar danielbankhead avatar dirk-thomas avatar github-actions[bot] avatar ianhowe76 avatar indutny-signal avatar jan-auer avatar jportner avatar knoxcard avatar krinkle avatar lpinca avatar lukekarrys avatar marco-c avatar mceido avatar mehulkar avatar mook-as avatar nebulade avatar pimterry avatar rimiti avatar sadasant avatar stoically avatar striezel avatar tareksha avatar tootallnate avatar tschlechtweg avatar unhappychoice avatar viktor-urbanas-qatalog avatar wikirik avatar yuecchen avatar zkochan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

proxy-agents's Issues

The option for connecting with TLS should be "protocol"

README.md says to set secureProxy to true if you want to connect to the proxy with TLS. I think it should be "protocol: 'https'" instead. secureProxy seems to be an internal variable which is set based on the value of "protocol", not the other way around.

Can I force HttpsProxyAgent to trust a certain certificate?

I want to use this module to pipe node-fetch requests through Fiddler for debugging. But when I try, I get an error about being unable to verify "the first certificate". This isn't unexpected, you get this with Firefox too - you have to export the cert from Fiddler as a .cer file and manually import it into Firefox.

Can you import a .cer file into this module to do something similar? Is there a workaround?

latest packages

Please rebuild and publish to npm. The latest version of "debug" has a security fix for its dependency "ms".

Socket not emitting data when proxy fails

Hello guys,

I have one problem currently and a possible solution for it.
I am using node-https-proxy-agent#3.0.1 with axios#0.19.0.

It works properly when the proxy connects successfully. The problem comes when my proxy provider gives me an error response like HTTP/1.1 502 Proxy Error during the connection process. When this happens, I am unable to catch this response and then, a timeout is thrown by my axios instance.

This is the case for all version beyond node-https-proxy-agent#2.2.1, the one that fixed a major security flaw. Reading axios code, I saw that it does not handle the closed socket properly, expecting the normal stream events to properly execute.

This way, I chose to do the following:

// ...
// Replaced the following
// socket.push(buffers)
// with
socket.emit('data', buffers);
socket.emit('end');
// ...

Here a way to reproduce the problem:

const axios = require("axios");
const HttpsProxyAgent = require("https-proxy-agent");

const agent = new HttpsProxyAgent("a:[email protected]:22225");

const instance = axios.create({
    baseURL: `https://example.com`,
    timeout: 10000,
    httpsAgent: agent,
    validateStatus: () => true // Accepts all status codes
});

instance.get().then(response => {
    // Expected a response with the proxy error here
    // It should give a response with a 407 Invalid Auth status
    console.log(response);
}).catch(error => {
    // A timeout error is thrown instead
    // Error: timeout of 10000ms exceeded...
    console.error(error)
});

Using the solution explained before, it worked. I would like to know if this is the best way to do this.

I am currently using this branch

BUG? Unhandled "socket hang up" crashes node process (incl. async stacktrace)

Using longjohn I was able to get the async stacktrace of an unhandled "socket hang up" error which results in killing the node process.

It's unhandled in that the error isn't exposed to the superagent.end(function(err,res), and also not on superagent.on("error", handleFN).

Here's the longjohn stacktrace:


Error: socket hang up
    at TLSSocket.onHangUp (_tls_wrap.js:1117:19)
    at emitNone (events.js:91:20)
    at TLSSocket.emit (events.js:186:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
---------------------------------------------
    at fireErrorCallbacks (net.js:473:15)
    at TLSSocket.Socket._destroy (net.js:480:5)
    at TLSSocket.Socket.destroy (net.js:527:8)
    at TLSSocket.onHangUp (_tls_wrap.js:1119:14)
    at emitNone (events.js:91:20)
    at TLSSocket.emit (events.js:186:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
---------------------------------------------
    at TLSSocket.Readable.on (_stream_readable.js:687:35)
    at TLSSocket.once (events.js:306:8)
    at Object.exports.connect (_tls_wrap.js:1122:10)
    at ondata (/Users/geert/sources/captured/pricing/node_modules/https-proxy-agent/https-proxy-agent.js:144:20)
    at Socket.read (/Users/geert/sources/captured/pricing/node_modules/https-proxy-agent/https-proxy-agent.js:82:12)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:186:7)
    at emitReadable_ (_stream_readable.js:432:10)
    at emitReadable (_stream_readable.js:426:7)
    at readableAddChunk (_stream_readable.js:187:13)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:551:20)
---------------------------------------------
    at Socket.Readable.on (_stream_readable.js:687:35)
    at Socket.once (events.js:306:8)
    at read (/Users/geert/sources/captured/pricing/node_modules/https-proxy-agent/https-proxy-agent.js:83:17)
    at HttpsProxyAgent.connect [as callback] (/Users/geert/sources/captured/pricing/node_modules/https-proxy-agent/https-proxy-agent.js:187:5)
    at ProxyAgent.connect [as callback] (/Users/geert/sources/captured/pricing/node_modules/proxy-agent/index.js:147:9)
    at ProxyAgent.Agent.addRequest (/Users/geert/sources/captured/pricing/node_modules/agent-base/agent.js:81:8)
    at new ClientRequest (_http_client.js:212:16)
    at Object.request (http.js:26:10)
    at Object.request (https.js:206:15)
    at Object.request (/Users/geert/sources/captured/pricing/node_modules/agent-base/patch-core.js:52:20)
    at Request.request (/Users/geert/sources/captured/pricing/node_modules/superagent/lib/node/index.js:594:28)
    at Request.end (/Users/geert/sources/captured/pricing/node_modules/superagent/lib/node/index.js:750:8)
    at Promise (/Users/geert/sources/captured/pricing/src/drivers/driverMain.js:144:18)
    at Promise._execute (/Users/geert/sources/captured/pricing/node_modules/bluebird/js/release/debuggability.js:300:9)
    at Promise._resolveFromExecutor (/Users/geert/sources/captured/pricing/node_modules/bluebird/js/release/promise.js:483:18)

Need support to additional HTTP headers on opening connection to proxy

The Secure Proxy I connect to requires a Proxy-Authentication header whose value does not follow the Basic <Base 64 value> format.

In order to address my current issue and also to give more flexibility in the HTTP connect request, I already have a patch that adds support to additional headers (described as a headers object inside the opts passed to the HttpProxyAgent)

Please let me know if that approach is acceptable, so I can send a pull request,

Thanks

old debug version ddos vulnerability

Testing /usr/lib/node_modules/npm...
✗ Low severity vulnerability found on [email protected]
- desc: Regular Expression Denial of Service (ReDoS)
- info: https://snyk.io/vuln/npm:debug:20170905
- from: [email protected] > [email protected] > [email protected] > [email protected] > [email protected]
Your dependencies are out of date, otherwise you would be using a newer debug than [email protected].
Try deleting node_modules, reinstalling and running `snyk test` again.
If the problem persists, one of your dependencies may be bundling outdated modules.

✗ Low severity vulnerability found on [email protected]
- desc: Regular Expression Denial of Service (ReDoS)
- info: https://snyk.io/vuln/npm:debug:20170905
- from: [email protected] > [email protected] > [email protected] > [email protected] > [email protected]
Your dependencies are out of date, otherwise you would be using a newer debug than [email protected].
Try deleting node_modules, reinstalling and running `snyk test` again.
If the problem persists, one of your dependencies may be bundling outdated modules.

Tested 358 dependencies for known vulnerabilities, found 1 vulnerability, 2 vulnerable paths.

How can i set http.Agent , keepalive property

How can i set the original keepalive option to true when settings the agent to instance of http.
var HttpsProxyAgent = require('https-proxy-agent'); this.agent = new HttpsProxyAgent("http://example.proxy.com");
however i want to set the original option of http.Agent({ keepAlive: true }); is there a way to accomplish this. what is the default keepalive behavior when using the proxy

A fresh release ?

Could you please release a new version (0.3.6) to make available dependencies updates. (debug and mocha)

changing proxy tartget url based on the locale

I'm working on an app that has different servers per country and I want to target this by changing the proxy target URL based on the locale. For instance, for US-based users, I'm targeting the below.

const proxyConfig = [
  {
    context: '/api',
    pathRewrite: { '^/api': '' },
    target: 'https://company.com',
    changeOrigin: true,
    secure: true
  }
];

For AU-based users, I'm targeting the below.

const proxyConfig = [
  {
    context: '/api',
    pathRewrite: { '^/api': '' },
    target: 'https://company.com.au',
    changeOrigin: true,
    secure: true
  }
];

How do I do this by only changing the target to different URL based on locale?

Confused to use proxy-agent

Hello,

sorry for my bad english... I have build a ws-server for my website (run over apache/nginx), now i need a way to accept clients (website users) that use an proxy. I think your proxy-agent is the solution, or?
Unfortunately, I can not get it started.

var proxy = process.env.http_proxy || 'http://89.163.255.9:3128'; 
  • process.env.http_proxy, is always undefined. why?
  • What for ip/port i must set (i know not the port of nginx)?
  • Why http://? I need only a https solution, my website can not be opened over http://...
var endpoint = process.argv[2] || 'wss://mydomain.com:8080';

I know, our target is build a tunnel form client (website user) to webSocket-server, the endpoint is this server that i start now.

I have some values tested, all get errors on the console.
proxy-agent works without changes on nginx.conf?
I hope you can help.

Greeting

Incorrectly routing HTTPS requests to port 80 on node 0.12+

Raised from a question on Stack Overflow there seems to have been some change in Node 0.12 that is causing the incorrect port to be sent on HTTP CONNECT requests.

I've pinned it down to the fact that the opts being passed in to the connect method has the port set to 80. When you're merging together these passed in options with your defaults its overriding the secureDefaults port 443 with 80. The request is therefore going to the wrong port on the endpoint which is rejecting it

Error: write EPROTO 140735203734288:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:782:

I've done a rudimentary patch to demonstrate this that flips the order of the merge but this means that there's no way to connect to an HTTPS service on any other port so I don't think its the long term solution.

timrwilliams@52f9bde

Any thoughts on how to proceed?

ERR_UNEXPECTED_PROXY_AUTH in chrome

I am using it in combination with http-proxy-middleware
but getting ERR_UNEXPECTED_PROXY_AUTH in crhome network console.

any idea how to fix it? I tried multiple variations.

"undefined is not a function" => Object.assign

When using https-proxy-agent in my context, I had this error :

"Undefined is not a fonction at index.js:35"

After some research, I found that I had to add a new dependency to my module in order to work because Object.assign wasn't supported.

I add the module babel-polyfill and load it (require("babel-polyfill");) at the very beginning of my module using https-proxy-agent and it works.

I think adding this dependancy directly in your module could help some people who have same issue.

Ps: Sorry for my bad English !

Not possible to disable TLS negotiation with secureProxy = false

Based on the configuration options, it appears that you can use a plain HTTP proxy with HTTPS request URLs (which will use the CONNECT method). Unfortunately it looks like this option just alters when the TLS negotiation is made:

  • secureProxy true: TLS connection made on request initiation
  • secureProxy false: TLS upgrade performed after successful response coming back from the proxy.

For many cases (e.g. internal corporate proxy on a trusted network) it is acceptable to use a plaintext connection to the proxy and not upgrade to TLS when using an HTTPS request endpoint. Unfortunately it's not possible since secureProxy is not taken into account when the connection is made to the proxy, only secureEndpoint.

Add a browser.js to make bundling for browser & node usage simpler

WS implements a simple browser.js file that makes webpacking a simple exercise as it injects an error if use is attempted (which is shouldn't be).

Can https-proxy-agent do the same so something that uses it but targets both browser and node can have a simple webpack story?

Error: connect EINVAL

Somehow I can not get it to work. Wget can fetch the page through the https proxy. Any advice would be greatly appreciated. Below is the console output. Many thanks.

using proxy server "<internal company proxy>"
attempting to GET "https://download.01.org"

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect EINVAL
    at errnoException (net.js:904:11)
    at connect (net.js:766:19)
    at net.js:845:9
    at asyncCallback (dns.js:68:16)
    at Object.onanswer [as oncomplete] (dns.js:121:9)

this.socket.destroy is not a function

After upgrading to v3, I started to get errors:

TypeError: this.socket.destroy is not a function
    at ClientRequest.abort (_http_client.js:328:17)
    at Immediate.timeoutHandler (/srv/node_modules/got/source/utils/timed-out.js:66:11)
    at processImmediate (internal/timers.js:441:21)
    at process.topLevelDomainCallback (domain.js:131:23)

So far I wasn't able to isolate what is causing them.

Can't set connect and read timeout before connection is fully established to endpoint

With the current implementation I can't get hold of the socket and set a timeout before the proxy connection to the final endpoint has succeeded.

The following code doesn't work because the 'socket' event is emitted too late

req.on('socket', function(socket) {
    socket.setTimeout(5000);
});

This doesn't work either as node's http client propagates the request's setTimeout either after 'connect' or after 'socket' depending on the situation

req.setTimeout(5000);

Support Windows Integrated Credentials with NTLM Proxy

Git and NPM support this syntax: http://:@proxyserver:80
Instead of supplying a username:password before the @ symbol the username and password is left blank. This is great because obviously you don't want your real username and password in plain text in an npmrc file or environment variable. Is there any way to support that using this library?

Possible to pass https.Agent options

I've been using https-proxy-agent with great success to make aws-sdk calls through a corporate proxy like so:

awsConfig.httpOptions.agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);

However there is known node issue connecting to DynamoDB that requires setting the agent like so:

awsConfig.httpOptions.agent = new https.Agent({
  rejectUnauthorized: true,
  keepAlive: true,                // workaround part i.
  secureProtocol: 'TLSv1_method', // workaround part ii.
  ciphers: 'ALL'                  // workaround part ii.
});

I don't see how to pass keepAlive, secureProtocol, and ciphers to the https-proxy-agent.

Error event is not emitted

I have an error with a proxy (186.121.206.234:1080). This proxy doesn't work, I know, but when I use them with the agent I can't receive any error event. The script only terminate without any error or event.

I extracted the problem in a simple code. I'm using 2.2.1 version of the agent.

var url = require('url');
var https = require('https');
var HttpsProxyAgent = require('https-proxy-agent');

// HTTP/HTTPS proxy to connect to
var proxy = 'http://186.121.206.234:1080';
console.log('using proxy server %j', proxy);

// HTTPS endpoint for the proxy to connect to
var endpoint = 'https://httpbin.org/ip';
console.log('attempting to GET %j', endpoint);
var options = url.parse(endpoint);

// create an instance of the `HttpsProxyAgent` class with the proxy server information
var agent = new HttpsProxyAgent(proxy);
options.agent = agent;

https.get(options, function (res) {
  console.log('"response" event!', res.headers);
  res.pipe(process.stdout);
}).on('error', (e) => {
  console.error(e);
});

And this is a response when I use with the debug flag: DEBUG=* node app.js

using proxy server "http://186.121.206.234:1080"
attempting to GET "https://httpbin.org/ip"
  https-proxy-agent creating new HttpsProxyAgent instance: Url { protocol: 'http:', slashes: true, auth: null, host: '186.121.206.234:1080', port: '1080', hostname: '186.121.206.234', hash: null, search: null, query: null, pathname: '/', path: '/', href: 'http://186.121.206.234:1080/' } +0ms
  https-proxy-agent onend +1s
  https-proxy-agent onclose had error false +1ms

Deploy on Azure failed

Hi,

I have a problem when I deploy my angular app with your package:

npm install
npm ERR! path D:\home\site\repository\src\client\node_modules.staging\npm-d4c06741\node_modules\libnpmhook\node_modules\npm-registry-fetch\node_modules\make-fetch-happen\node_modules\http-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise
npm ERR! code EINVAL
npm ERR! errno -4071
npm ERR! syscall rename
npm ERR! EINVAL: invalid argument, rename 'D:\home\site\repository\src\client\node_modules.staging\npm-d4c06741\node_modules\libnpmhook\node_modules\npm-registry-fetch\node_modules\make-fetch-happen\node_modules\http-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise' -> 'D:\home\site\repository\src\client\node_modules.staging\es6-promise-3ac93eae'

The problem is due to Azure who have issue to rename long path, Is there a way on your side to help me to fix this issue?

Probably not, but I tried so many different solutions which didnt work that now, I try other possibilities.

Thanks

could i use localAddress on ws?

I set 10.255.210.86 in code, but it seems not working, still use prev ip 10.255.210.84.

Node: 8.9.4 ws: 3.3.3 https-proxy-agent: 2.1.1
System config

[root@web-1 ~]# ifconfig -a
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.255.210.84  netmask 255.255.255.0  broadcast 10.255.210.255
        inet6 fe80::997c:fa81:8942:2647  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:6c:74:09  txqueuelen 1000  (Ethernet)
        RX packets 499  bytes 36048 (35.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 139  bytes 42478 (41.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens160:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.255.210.86  netmask 255.255.255.0  broadcast 10.255.210.255
        ether 00:0c:29:6c:74:09  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 6  bytes 504 (504.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 504 (504.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

my code can work, when i did not add localAddress parmas

let virtualIp = '10.255.210.86';

let proxyOpt = url.parse('http://xxxx:yyy');
proxyOpt.localAddress = virtualIp;

let wsOpt = {
  agent: new HttpsProxyAgent(proxyOpt),
  handshakeTimeout: 15000,
  localAddress: virtualIp,
  rejectUnauthorized: false
}

this.wsSock = new WebSocket(this.wsAddr, wsOpt);
netstat -antup
tcp        0      0 10.255.210.84:36576     125.211.211.171:18187   ESTABLISHED 1462/node           
tcp        0      0 10.255.210.84:18262     125.211.211.170:21438   ESTABLISHED 1462/node           
tcp        0      0 10.255.210.84:23489     125.211.211.175:18640   ESTABLISHED 1462/node           
tcp        0      0 10.255.210.84:25770     125.211.211.176:19905   ESTABLISHED 1462/node           
tcp        0      0 10.255.210.84:41199     125.211.211.171:24938   ESTABLISHED 1462/node           
tcp        0      0 10.255.210.84:61717     125.211.211.176:21612   ESTABLISHED 1462/node           

10.255.210.84 be used?
Agent (HttpsProxyAgent) be used for this websocket, is it problem?

Outdated version of debug - Snyk

Need to upgrade to the latest version of debug
https://github.com/visionmedia/debug/releases/

✗ Low severity vulnerability found on [email protected]

how can i use ws with HttpsProxyAgent

My project is create a websocket connection between my computer and a internet websocket server.
Now I want to use proxy.
I get some proxy IP from Internet. Such as: 'http://51.38.71.101:8080'.

Here is my code:

var WebSocket = require('ws');
var http = require("http");
var HttpProxyAgent = require('http-proxy-agent');
var HttpsProxyAgent = require('https-proxy-agent');
var urlUtil = require('url');

var reconnectInterval = 30 * 1000;
var reconnectTimeCount = 0;
var reconnectTotalCount = 10000;
var socket;
var proxy = 'http://51.38.71.101:8080';
var options = urlUtil.parse(proxy);
// var agent = new HttpsProxyAgent(options);
var agent = new HttpProxyAgent(options);

var connect = function(){
    try {
        console.log("========000000======");
        var url = 'ws://115.231.140.70';
        // socket = new WebSocket(url, { agent: agent });
        socket = new WebSocket(url);
        console.log("========1111======");
        socket.on('open', function() {
            console.log("=====connect====success====");
        });
        socket.on('message', function (data, flags) {
            console.log("=====received msg====");
        });
        socket.on('error', function(err) {
            console.log("************" + 'socket error'+ require('util').inspect(err));
        });
        socket.on('close', function() {
            console.log('socket close' + "===============reconnectTimeCount="+reconnectTimeCount);
            if (reconnectTimeCount <= reconnectTotalCount) {
                setTimeout(connect, reconnectInterval);
                reconnectTimeCount ++;
            }
        });
        console.log("========222222======");
    } catch (e) {
        console.log("========333333======");
    }   
    
};

connect();

When I use socket = new WebSocket(url);, my console log is:

SyterLius-MacBook-Air:app Syter$ node test.js 
========000000======
========1111======
========222222======
=====connect====success====

But when I use socket = new WebSocket(url, { agent: agent });, my console log is:

SyterLius-MacBook-Air:app Syter$ node test.js 
========000000======
========1111======
========222222======
************socket errorError: Unexpected server response: 101
    at ClientRequest.req.on (/Users/Syter/Documents/workcode/moshan/hyserver/node_modules/ws/lib/websocket.js:579:7)
    at ClientRequest.emit (events.js:188:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:562:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)
    at Socket.socketOnData (_http_client.js:449:20)
    at Socket.emit (events.js:188:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:145:17)
socket close===============reconnectTimeCount=0

I have test proxy IP in http.get way like documents said, it's no problem
So how can I do for it??

conditional proxy-servers

Is it possible to setup https-proxy-agent so that it can use different proxy servers based on url path request?

For example:

If url path request is /app/microsoft, the proxy to use is proxy-1.example.com
If url path request is /app/linux, the proxy to use is proxy-2.example.com

Problem when upgrading from Angular7 to Angular8

Hi folks

I have updated my application from ANgular 7.2.9 to Angular 8.2.3. In our project we are using Win Auth.

After the upgrade the login is not working any longer. No requests arrive at the backend.

Any idea or plans?

Cheers

Marc

Proxy authentication (username, password)

Hello,

Is the proxy authentication implemented ? Cannot find it, e.g.a proxy requires username and password else status 407 will be returned...

I would be appreciated for any help,
David

Add a typescript definition file

Using this library in typescript is impossible (with noImplicitAny option enabled) as there is no definition file.

Would you mind adding one ?

Keep-Alive Support

There is plans to add Keep-Alive support to this agent? or do you know any tunneled proxy implementation with keep-alive / persistent connection support?

Http headers

Hey mate,

I noticed that when using the agent, if I have added header to the request they are not showing up in the webserver access logs. If I am reading the code correctly headers from the original request are not merged with the proxied request. Or am I doing something wrong???

If it is the case that headers from the original request should be merged in ... I'm happy to raise a pull request. 🎉

Cheers,
m

Options passed into HttpsProxyAgent() constructor aren't propagated to tls.connect() when switching to the TLS handshake

The options that are passed in to the constructor at index.js:25 (and eventually assigned to this.proxy) are not propagated to the call to tls.connect() at index.js:153. This means that attempting to alter TLS behavior from the default with a statement like new HttpsProxyAgent({ rejectUnauthorized: false }) doesn't work.

I suggest a fix something like this:

      if (opts.secureEndpoint) {
        // This line is the fix.
        opts = Object.assign({}, proxy, opts);

        // since the proxy is connecting to an SSL server, we have
        // to upgrade this socket connection to an SSL connection
        debug(
          'upgrading proxy-connected socket to TLS connection: %o',
          opts.host
        );
        opts.socket = socket;
        opts.servername = opts.servername || opts.host;
        opts.host = null;
        opts.hostname = null;
        opts.port = null;
        sock = tls.connect(opts);
      }

socket connection event is not emitted

When the connection of client---proxy---server is established successfully, socket connection event is not emitted.

I should register callback on this connection event. But the event can not be triggered.
However, node-http-proxy-agent is OK for connection event.

Do not include the port number in the Host

https://github.com/TooTallNate/node-https-proxy-agent/blob/6bbbef774527c8bdb5bf013d9ecc545ceaa7c974/https-proxy-agent.js#L192

This is making requests against multiple websites fail, e.g.

MacBook-Pro~ % curl 'http://www.watershed.co.uk/whatson/calendar/' -H 'Host: www.watershed.co.uk' -I
HTTP/1.1 200 OK
Date: Tue, 24 Jan 2017 21:44:16 GMT
Server: Apache/2.4.16 (FreeBSD) OpenSSL/1.0.1j-freebsd PHP/5.6.12
X-Powered-By: PHP/5.6.12
X-Drupal-Cache: MISS
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, no-transform
X-Content-Type-Options: nosniff
Content-Language: en
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=edge
X-Generator: Drupal 7 (http://drupal.org)
Link: <http://www.watershed.co.uk/whatson/calendar>; rel="canonical",<http://www.watershed.co.uk/whatson/calendar>; rel="shortlink"
Vary: User-Agent
Content-Type: text/html; charset=utf-8

MacBook-Pro~ % curl 'http://www.watershed.co.uk/whatson/calendar/' -H 'Host: www.watershed.co.uk:80' -I
HTTP/1.1 404 Not Found
Date: Tue, 24 Jan 2017 21:44:26 GMT
Server: Apache/2.4.25 (FreeBSD) OpenSSL/1.0.1s-freebsd
Content-Type: text/html; charset=iso-8859-1

Need to support SNI

While I'm using https-proxy-agent to send request, if the request option set servername (which might not the same as host) https-proxy-agent will ignore my servername, this will cause the certificate error.

      if (opts.secureEndpoint) {
        // since the proxy is connecting to an SSL server, we have
        // to upgrade this socket connection to an SSL connection
        debug('upgrading proxy-connected socket to TLS connection: %o', opts.host);
        opts.socket = socket;
        **opts.servername = opts.host;**
        opts.host = null;
        opts.hostname = null;
        opts.port = null;
        sock = tls.connect(opts);
      }

Could you please change this part to:
opts.servername = opts.servername?opts.servername:opts.host;
so that it can support SNI?

Improper Client Certificate Handling

Description: Currently, node-https-proxy-agent will forward client certificate used to authenticate against proxy to the backend server (being proxied by the proxy) as well. This would be undesirable behavior when both the site being proxied and the proxy itself enabled client certificate authentication, and they expect different client TLS certificates. I added backendOpts option to specify TLS options specifically for backend server.

#55

Failing unit test in Node 10+ (connection timeout)

The unit test of the https-proxy-agent package fails on Node 10+:

  1) HttpsProxyAgent "http" module should work over an HTTP proxy:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  
  2) HttpsProxyAgent "http" module should work over an HTTPS proxy:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  
  3) HttpsProxyAgent "after all" hook:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

I suspect this is related to the following change introduced in Node 10: nodejs/node#19981

Unfortunately, this issue makes it impossible to use web sockets over HTTPS proxy, since that depends on https-proxy-agent. For example, unit tests of https://github.com/apifytech/proxy-chain fail for this reason (see https://github.com/apifytech/proxy-chain/blob/master/test/server.js#L612)

Timeout doesn't work with node-fetch

Hi, I have this simple code and the timeout doesn't work with node-fetch library.
I'm trying to use this proxy 192.40.242.55:53281 (doesn't work, I know) and the timeout doesn't work.

var fetch = require('node-fetch');
var HttpsProxyAgent = require('https-proxy-agent');

var proxy = 'http://192.40.242.55:53281';
var options = {
    timeout: 5000,
    agent: new HttpsProxyAgent(proxy),
};

var time = +new Date();
fetch('http://httpbin.org/ip', options)
	.then(res => res.json())
	.then(json => {
		console.log(json);
		console.log('Time: ' + (+new Date() - time));
	})
	.catch(err => {
		console.error(err);
		console.log('Time: ' + (+new Date() - time));
	});

My response using the debug flag: DEBUG=* node app.js:

  https-proxy-agent creating new HttpsProxyAgent instance: Url { protocol: 'http:', slashes: true, auth: null, host: '192.40.242.55:53281', port: '53281', hostname: '192.40.242.55', hash: null, search: null, query: null, pathname: '/', path: '/', href: 'http://192.40.242.55:53281/' } +0ms
{ FetchError: request to http://httpbin.org/ip failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (/Users/rodolfo/Downloads/proxies/node_modules/node-fetch/lib/index.js:1393:11)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at onerror (/Users/rodolfo/Downloads/proxies/node_modules/agent-base/index.js:101:9)
    at callbackError (/Users/rodolfo/Downloads/proxies/node_modules/agent-base/index.js:123:5)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  message: 'request to http://httpbin.org/ip failed, reason: read ECONNRESET',
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET' }
Time: 48375

The request took 48375 milliseconds instead of 5000 of my timeout.
I tested the above code with the http-proxy-agent library and works perfectly.

Any idea that what happened?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.