Created by: krassif
Status
READY
Migrations
NO
Description
Single proxy may handle requests targeting multiple "hosts"/ DNS entries and then distribute the load as per the caller specified host. Both target host and target port are part of the load distribution.
For instance, consider the following distribution spec:
var binding = {
"yarn.pronto.peerbelt.com": {
target: "https://yarnpkg.com:443",
"changeOrigin": true
},
"google.pronto.peerbelt.com": {
target: "https://www.google.com:443",
"changeOrigin": true
},
"*.pronto.peerbelt.com": {
target: "https://www.microsoft.com:443/en-us/",
"changeOrigin": true
},
"pronto.peerbelt.com": {
target: {
host: "overlayads.herokuapp.com",
port: 443,
protocol: "https"
},
changeOrigin: true
}
};
Based on it, HTTP request targeting:
-
yarn.pronto.peerbelt.comare getting forwarded tohttps://yarnpkg.com:443 -
pronto.peerbelt.comcallsoverlayads.herokuapp.com -
something-different.pronto.peerbelt.comfollows the wildcard rule hittinghttps://www.microsoft.com:443/en-us/accordingly
Anything not found in the distribution spec follows the already existing proxy rules. For instance:
httpProxy.createServer({
binding: binding,
target: {
host: "localhost",
port: 3030
}
}).listen(80)
.on( "error", socketErrorHandler );
with incoming request targeting my.peerbelt.com is simply forwarded to localhost:3030.
Todos
-
Tests