Search code examples
node.jssslproxysquid

node server placed behind proxy server failed to GET request to https://localhost:<port>


On my machine, im hosting a node server that is listening on port 5000. Before setting up a forward proxy (squid), i was able to perform a GET on https://localhost:<port>. However, after setting up a forward proxy and setting the environmental variable http_proxy=<ip addr:port>, this GET request no longer works.

The error that shows up is: tunnelling socket could not be established, statusCode=503

Some additional information:

  • The proxy server works as I am able to connect to the internet via it.
  • Performing curl instead, on the https:localhost:5000/api works.
  • Am using request.js for the requests, using agentOptions to specify TLS protocols & ca cert.

I am hoping to understand how the traffic is now different after i add in a proxy. From my understanding, now we have to go through a sort of TLS CONNECT / tunnelling since to the proxy first, since its a HTTPS request, before coming back to my localhost. But in the case without the proxy, how is it that its working?

Any help would be greatly appreciated. Thanks!


Solution

  • you must add export no_proxy='localhost,127.0.0.1' the https work because you don't use proxy for https , you must set https_proxy='<tour_proxy>'