Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm new in
Node.JS
and deployed the first application on VPS.
After running on port
8000
, i decided create a
http-proxy
for forward each domain to its specific port .
I worte a little application like here :
var http = require('http'),
httpProxy = require('http-proxy');
var option = {
router : {
'domain.com' : 'http://88.198.86.100:8000'
var proxyServer = httpProxy.createServer(option);
proxyServer.listen(80);
88.198.86.100 is my server ip
.
So, my problem here is shown , when i typed 88.198.86.100
in my browser PC (Google Chrome), my proxy application in server was carshed and gave this error :
C:\Users\Administrator\Desktop\Nodejs\node_modules\http-proxy\lib\http-proxy\index.js:119
throw err;
Error: Must provide a proper URL as target
at ProxyServer.<anonymous> (C:\Users\Administrator\Desktop\Nodejs\node_modules\http-proxy\lib\http-proxy\index.js:68:35)
at Server.closure (C:\Users\Administrator\Desktop\Nodejs\node_modules\http-proxy\lib\http-proxy\index.js:125:43)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
error: Forever detected script exited with code: 1
I want to someone enter IP server into the each browser, my application will not crash.
require('http').createServer(function(req, res) {
proxy.web(req, res, {
target: options[req.headers.host]
}).listen(80);
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.