Skip to content
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 to https errors in Node 0.12 #24

Closed
noahgrant opened this issue Sep 9, 2015 · 4 comments
Closed

proxy to https errors in Node 0.12 #24

noahgrant opened this issue Sep 9, 2015 · 4 comments
Labels

Comments

@noahgrant
Copy link

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!

@noahgrant
Copy link
Author

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

@chimurai
Copy link
Owner

chimurai commented Sep 9, 2015

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
              });

@noahgrant
Copy link
Author

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!

@VirtueMe
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants