New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxy chain with SSL (connect) #700
Comments
@earroyoron could you give some code and maybe be more specific on the issue? If there is another proxy in the mix that is being tunneled through, you probably want to pass in something like |
@jcrugzz Trying to be more specific: I have the below code working; in that scenario: This is my code working for the first scenario: // Create an HTTP tunneling proxy proxy.on('connect', function(req, cltSocket, head) { |
Have the proxy forward the request data to an http.request() method, and then in the callback function, pipe the response back to the proxy and that'll allow you to use node-http-proxy in the manner you're describing. Also keep in mind that tunneling SSL is somewhat difficult. So, I suggest referring to the pem module for help in resigning the certificate for when the proxy communicates back to the client, it still shows as a trusted connection. |
@gm112 I tried to email you, but it looks like your domain is down. Can you give an example of what that would look like? A forwarded request using http.request? |
http://nodejs.org/api/http.html#http_http_request_options_callback This is the method you would use. So, add a listener on your HTTPS server, "connect", (http://nodejs.org/api/http.html#http_event_connect) and within this body, use the http.request method to call out to where ever you're going. Mind you, if you're trying to tunnel SSL to any site, you're going to have to generate SSL certs on your SNI callback method. Otherwise, you're fine just using whatever cert you provide the https.createServer() method. If I wasn't mobile I'd give you sample code but I tried my best to point you in the direction atm. ;) |
I am still not 100% sure how to accomplish this. I looked at the http.request method, but it doesn't look like you can set a proxy on that. I am trying to do the same thing described above: CLIENT --> PROXY --> PROXY2 --> TARGET Etc. |
http.request(); itself doesn't proxy. Here, take this really rough code for example. And it sounds like what you're doing can be accomplished by using node-cluster in conjunction with node-http-proxy and the http/https/url libraries. Cluster would act as the main "Proxy" or "load-balancer", then Proxies 0 - 4 would be your worker processes, which would then forward the request to the target and finaly back around to the client. // Setup HTTP server self.httpServer.addListener('connect', function (request, socket, head) { var onRequest = function (request, response) { .. } tunnelRequest.on('end', function () { tunnelRequest.on('error', function(error) { } |
I think my problem is here: use node-http-proxy here and pass on the request,socket,and head. I can catch the connect event, but no matter what code I put in there, I cannot get a successful response to the client. Even if I forget the PROXY2 or PROXY3 value. proxy_server.ws(req, socket, head); Would you be willing to consult for a quick period of time? I really want to get past this bug. |
Despite the awesome module, I can't get a proxy chain when using SSL, and I have try everything, so maybe here someone can help me:
In any case I can get the client connected and using the proxy-chain and I do not found how to resolve this.
The main idea is that the first proxy is somehow like a balancer that gets the better 2nd proxy for each request.
Not sure if this post is appropiate as an issue but didnt find a better place :o(
The text was updated successfully, but these errors were encountered: