-
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
Cannot call method 'split' of undefined #800
Comments
@efkan It's possible the source of your woes is |
Thank you very much, I've spent 11 hours today but I guess I have to spent much more time to learn the use. I just want a simple conditional route operation. Because I have to use only one port [iptables 443 -> 1443] for two different subdomains (with two certificates). But I couldn't the most basic this operation yet! Actually I read comment that you've indicated. But unfortunately I couldn't understand. |
I've simplified my question and I added my new experiences.. |
@efkan It's necessary for you to write the logic yourself. For example: var http = require('http');
var httpProxy = require('http-proxy');
var targets = {
'process.localhost': 'process.localhost:2443',
'api.localhost' : 'api.localhost:3443'
};
var proxy = httpProxy.createServer({changeOrigin: true})
http.createServer(function(req, res) {
/* target NOT forward
* target === final server to receive request
* forward === another proxy server to pass request through
*/
var options = {
target: targets[req.headers.host]
};
proxy.web(req, res, options, errorCallback); // errorCallback is optional
}).listen(1443); I have had a similar use case, but using a single domain and the first path to identify where to proxy requests. You can read it here: https://github.com/damonmcminn/api-proxy |
Really thanks @damonmcminn 🌟 ! I understood Thank you again for your helps.. ps: I got an error as |
@efkan No problem! The error is because |
Thank you again! You made my day! Probably there is another problem with my codes or It indicates;
and server.js line 56 is; and my targets are;
|
Your targets should be in this form: { 'sub.domain': 'protocol://sub.domain:port' } This is because For example: { 'api.localhost': 'http://api.localhost:3443' } Does this make sense? |
I see, OK. Thank you again... I checked it and I saw I owe you a coffee 😃
|
No problem :) On 7 April 2015 at 11:36, efkan notifications@github.com wrote:
{ |
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 toprocess.localhost:2443
andif a user call
api.localhost:1443
then I should route the call toapi.localhost:3443
what's happening
I wrote the below server.js codes.
If I change
httpProxy.createServer(options)
line withhttpProxy.createServer({target:'http://process.localhost:2443'})
then it works properly!Otherwise 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 asundefined
.What should I do?
server.js
The text was updated successfully, but these errors were encountered: