0

is it possible to make nodejs script listen to same port(80) just like php.

For php, it should be www.abc.com/script1.php

www.abc.com/script2.php

equal to

www.abc.com:80/script1.php

www.abc.com:80/script2.php

but for nodejs script(script1.js, script2.js), how to set parameters to make multi scripts listening to 80 and processing related script when get the requests?

Your comment welcome

arachide
  • 8,006
  • 18
  • 71
  • 134
  • that is not my question, I mean if it is possible for different nodejs script listen to same port? – arachide Dec 31 '13 at 10:41
  • There is nothing like "node scripts", you use routes in Express, which is a single process; do you mean using the same port of Apache? In that case you can't and you'd need a proxy. – moonwave99 Dec 31 '13 at 10:46
  • 1
    Reading @CD's comment I got it - you just need module `http-proxy` [after having started your processes on different local ports, and having routed the traffic in 2 different routes, e.g. `/foo` -> `localhost:3333` and `/bar` -> `localhost:4444`]. – moonwave99 Dec 31 '13 at 11:23

1 Answers1

0

If you are interested in a node.js solution check out bouncy, a websocket and https-capable http router proxy/load balancer in node.js.

Define your routes.json like

 {
      "beep.example.com" : 8000,
      "boop.example.com" : 8001
 }

and then run bouncy using

 bouncy routes.json 80

other alternative to bouncy is http-proxy

Gaurav
  • 2,003
  • 1
  • 25
  • 50