http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.89k stars 1.97k forks source link

HTTPS Proxy -> Multiple External HTTP Server Instances #1210

Open macharborguy opened 6 years ago

macharborguy commented 6 years ago

I am trying to figure out how to combine a few of the examples provided into a Proxy server that can route traffic based on the requested domain name.

Currently I am using Bouncy to bounce traffic based on the requested Domain name, and it works well, but I am looking to expand to proxy HTTPS secure traffic to the http server instances, each server instance is a separate NodeJS process running an ExpressJS-based server. Bouncy doesnt appear to be maintained anymore, and it was suggested in the Issues tracker there to check out node-http-proxy. (i need HTTPS and WSS traffic support due to Twitch.tv requiring HTTPS/WSS for their Extensions interface)

The HTTPS->HTTP example is quite straight forward, but when I started looking into incorporating the "custom server logic" example, since it is a "stand alone" example, it has the server internal to the proxy script, rather than the Proxy and the Web Server being separate instances.

Is there any way of combining HTTPS->HTTP server to proxy HTTPS traffic to a separate HTTP ExpressJS server instance (also run on the localhost), perhaps using the "custom server logic" or "proxy request header re-writing" examples to intercept the request, check the domain name information against a list of possible domain names, and then route the request accordingly?

Again, I am already doing this with Bouncy with zero issues (not only redirecting requests to the proper server instance, but also redirecting/forwarding requests to other websites, in the case of "ExampleDomain.com/twitter" which redirects to our twitter page. I would much rather, however, use a more maintained module that has good support for HTTPS/WSS.

totoafrica commented 6 years ago

for your question of how to proxy based on domain, u can look at my code at issue: https://github.com/nodejitsu/node-http-proxy/issues/1228