Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Https to https proxy with routing table and self signed certificate does not work in node v0.10.x #409

Open
jclevy opened this Issue · 2 comments

3 participants

@jclevy

I had a simple proxy working in node v0.8.x (written in Coffeescript):

Fs = require 'fs'
HttpProxy = require 'http-proxy'

HttpProxy.createServer
    https:
        key: Fs.readFileSync './key.pem'
        cert: Fs.readFileSync './cert.pem'
    target:
        https:yes
    hostnameOnly: true
    router:
        'test1.domain.org': '127.0.0.1:8080'
        'test2.domain.org': '127.0.0.1:8081'
.listen(8000)

When I moved to node v0.10.x every request returned:

DEPTH_ZERO_SELF_SIGNED_CERT error

I did not find a way to configure my proxy to make it work.

I had to change http-proxy/lib/node-http-proxy.js

and insert : options.rejectUnauthorized = false;

exports._getAgent = function _getAgent (options) {
    ...
    options.maxSockets = options.maxSockets || maxSockets;
    options.rejectUnauthorized = false;
    agent = new Agent(options);
    ...
@DanH42

I'm also experiencing this problem. On node 0.10.10 and 0.10.11, I'm unable to get even the "Proxying to HTTPS from HTTPS" example to work, without modifications (other than inserting my certificate and key). When I run that example, I get an HTTP 500 with An error has occurred: {} and no errors in the console.

HTTP->HTTP and HTTPS->HTTP work fine.

@thejustinwalsh thejustinwalsh referenced this issue from a commit in thejustinwalsh/node-http-proxy
@thejustinwalsh thejustinwalsh Fixed https -> https proxying
Referenced in Issue #409
4038aad
@RGBboy

You shouldn't need to change anything. You can pass rejectUnauthorized when you create a new HttpProxy instance:

var proxy = new httpProxy.HttpProxy({
  target: {
    host: 'localhost', 
    port: 8443,
    https: true,
    rejectUnauthorized: false
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.