Http-proxy-middleware: proxy to https errors in Node 0.12

Created on 9 Sep 2015  路  4Comments  路  Source: chimurai/http-proxy-middleware

Hi,

When proxying to https, ie:

var myProxy = httpProxyMiddleware('/my-path', {target: 'https://mysslexample.com'});

I first get a 'Proxy created' message, but then when I try to go to /my-path, I get the following error:

[HPM] Proxy error: undefined mysslexample.com/my-path

and nothing works. It works in Node 0.10.33, but not in Node 0.12. Is this an http-proxy-middleware issue or an http-proxy issue?

Thanks!

question

Most helpful comment

Don't think it is an issue of the middleware.

Looking at the http-proxy proxy-http-to-https.js example, you'll need to configure the agent option:

var https = require('https');

var myProxy = httpProxyMiddleware('/my-path', {
                 target: 'https://mysslexample.com',
                 agent  : https.globalAgent               // <-- agent
              });

All 4 comments

btw, /my-path is on a local domain that is not https.

Don't think it is an issue of the middleware.

Looking at the http-proxy proxy-http-to-https.js example, you'll need to configure the agent option:

var https = require('https');

var myProxy = httpProxyMiddleware('/my-path', {
                 target: 'https://mysslexample.com',
                 agent  : https.globalAgent               // <-- agent
              });

ahh thanks for pointing me to that example. i also needed to set the host header as in that example in order for it to work, but it now does work!

@chimurai thanks for the agent tips, and thanks to @noahgrant for the host header information.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghostd picture ghostd  路  7Comments

zh-h picture zh-h  路  3Comments

villesau picture villesau  路  8Comments

lukaszpochrzest picture lukaszpochrzest  路  3Comments

nikksan picture nikksan  路  3Comments