substack/bouncy — Issue #24: How do we bounce to HTTPS site ?
Author: penkween
Created: 2012-02-17 04:47:56+00:00
State: open

Hi ,

How do we write a Forward Proxy using Bouncy listening at Port 8001 and bounce to External HTTPS site eg. https://encrypted.google.com

I have tried the following code (from https.js sample), but seem Do not work !

Proxy Codes:
=============================================================
var opts = {
key : fs.readFileSync('privatekey.pem'),
cert : fs.readFileSync('certificate.pem')
};

bouncy(opts, function (req, bounce) {
uri = url.parse(req.url);
port = 80;
if (uri.protocol == 'https:') { // NEVER HAPPENS :(
port = 443;
}

bounce(req.headers.host,port);

}).listen(8001);

Testing using Curl:
======================================================================================
c:\server\nodejs>curl -v -x localhost:8001 -k https://encrypted.google.com
* About to connect() to proxy localhost port 8001 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8001 (#0)
* Establish HTTP proxy tunnel to encrypted.google.com:443
> CONNECT encrypted.google.com:443 HTTP/1.1
> Host: encrypted.google.com:443
> User-Agent: curl/7.24.0 (i386-pc-win32) libcurl/7.24.0 OpenSSL/1.0.0g zlib/1.2.5 libssh2/1.3.0
> Proxy-Connection: Keep-Alive
>
* Proxy CONNECT aborted
* Closing connection #0
curl: (56) Proxy CONNECT aborted

Anyone, has any idea ?

Thanks.