I'm a newbie to node-http-proxy
module.
my aim
I need to use the module provide multi-SSL for multi-subdomain.
For example;
if a user call process.localhost:1443
then I should route the call to process.localhost:2443
and
if a user call api.localhost:1443
then I should route the call to api.localhost:3443
what's happening
I wrote the below server.js codes. However when I try to call process.localhost:1443
I get the following error;
D:\Work Space\...\http-proxy\node_modules\requires-port\index.js:13
protocol = protocol.split(':')[0];
TypeError: Cannot call method 'split' of undefined
protocol
seems as undefined
.
function required(port, protocol) {
protocol = protocol.split(':')[0];
What should I do?
server.js
var fs = require('fs'),
httpProxy = require('http-proxy'),
express = require('express'),
app = require('./app').service,
api = require('./api').service;
// PROXY
var options = {
changeOrigin: true,
forward: {
'process.localhost': 'process.localhost:2443',
'api.localhost' : 'api.localhost:3443'
}
}
httpProxy.createServer(options).listen(1443, function() {
console.log('Proxy is listening on port 1443')
})
// HTTP
app
.listen(2443, function() {
console.log('PROCESS APP server is listening on port 2443')
})
api
.listen(3443, function() {
console.log('API APP server is listening on port 3443')
})