-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Simple HTTP->HTTPS Proxy Example? #304
Comments
Never mind, I figured it out. I just had to ignore all the extraneous code in the HTTPS->HTTPS example. This will do it:
Beautiful! Thanks node-http-proxy! |
This doesn't work for me. I get:
(I have tried different hosts, of course) See also: http://stackoverflow.com/questions/15801014/how-to-use-node-http-proxy-for-http-to-https-routing Update: This did the trick: |
Can you repost your gist? :) |
Figured this out myself after tearing my hair out a bit. The above solution wouldn't work for me because I needed to inspect the request before proxying it. You need to place the require('http-proxy').createServer(function (req, res, proxy) {
// Inspect request and decide whether to proxy, then...
proxy.proxyRequest(req, res, {
host: 'secure.target.host',
port: 443,
target: {
https: true
}
});
}).listen(8080); |
There's an example in the examples folder now: https://github.com/nodejitsu/node-http-proxy/blob/caronte/examples/http/proxy-http-to-https.js
Worked for me. |
In case someone's having problem with it, I've created a simple working repo: https://github.com/ericmdantas/simple-node-https-proxy |
@ericmdantas I'm trying to use your repo to access secured web pages, but it seems to not be working because I get Secure Connection Failed in the web page... |
@Valeriu92, when I access |
It works for me only with secure: false in options which is unfortunate, becauase the target server has valid letsencrypt certificate. How do I debug the SSL layer verbosely to see why is the 'first certificate' invalid? |
I had to use these options
|
Hi,
I'm a node/node-http-proxy novice, and I'd like to use node-http-proxy to create an HTTP->HTTPS proxy server. I.e. a client would connect to the proxy over HTTP, and on the back-end it would talk to an HTTPS target web server. The two examples given are for HTTPS->HTTP and HTTPS->HTTPS, but not HTTP->HTTPS.
Maybe it's obvious from these examples how to do it, but I'm not able to figure it out.
Here's a sample of my code:
When I try to connect to http://localhost:8000 I get a 500 Internal Server Error with the body
If anyone can show me what I'm doing wrong, that would be greatly appreciated! Thanks!
The text was updated successfully, but these errors were encountered: