How setup a proxy server using node js ?

Viewed 210

i setup a proxy using node js my script is like this

var http = require('http'),
 httpProxy = require('http-proxy');
var options = {
  pathnameOnly: true,
  router: {
    '/wamp_application/': '127.0.0.1:80/',
    '/node_application': '127.0.0.1:1331',
    
  }
};


var proxyServer = httpProxy.createServer(options);
proxyServer.listen(8888);

now its working like this when i access 127.0.0.1:8888/wamp_application, i get 127.0.0.1:80 But i want like this

127.0.0.1:8888/wamp_application/app1 -> 127.0.0.1:80/app1 127.0.0.1:8888/wamp_application/app2 -> 127.0.0.1:80/app2 127.0.0.1:8888/wamp_application/app3 -> 127.0.0.1:80/app3 and so on

i tried like this

  router: {
        '/wamp_application/*': '127.0.0.1:80/*',
        '/node_application/*': '127.0.0.1:1331/*',
       };

it is not working. actually i want both php and node application access from same port. How can i do this ?

1 Answers
Related