0

I have several webservers running on a machine, and currently, in order to select which website you want to be served you must switch what port you are connecting on (domain:8000, domain:8001), however I really do not like this solution. My goal is to be able to connect via domain/process1, domain/process2 however the problem is the dns is always going to connect to domain:80 and then pass the route to express (What im using for the servers)

I am aware I could use express to control what code runs using

app.get('/process1', (req, res)=>{
   process1.getRequest(req, res);
   next();
});
app.get('/process2', (req, res)=>{
   process2.getRequest(req, res);
   next();
});

However, this requires all of my processes are running in a single instance of nodejs. My hope would be to not have to modify any of my current webservers and just create a single new process that will run on port 80 and redirect traffic to the different local ports based on the route.

I have seen This question however they have several domains whilst I only have a single domain. I also read a bit about a reverse-proxy/nginx, if at all possible I would love to stay within nodejs. Is it possible to create my own reverse-proxy in node?

Strike Eagle
  • 852
  • 5
  • 19

1 Answers1

1

You can have single domain and still use a reverse proxy like nginx.

Take a look at this article https://medium.com/@samanbaboli/how-to-load-balancing-nodejs-apps-using-nginx-a3b4ceb7c782.

Ps: you do not have necessary to pay to use nginx. https://www.nginx.com/resources/wiki/

Thierno Barry
  • 357
  • 1
  • 10
  • Good to know that nginx is free, however for me an optimal solotion would be one that I can do the need to install new services on my machine. Can I create my own reverse proxy somehow in nodejs or using the built in tools in linux (ubuntu)? – Strike Eagle Jan 09 '20 at 18:18