0

I have two react frontend servers (example1 and example2) listening on two ports on MyDomain.com: MyDomain.com:4000 accesses example1 MyDomain.com:5000 accesses example2

I have two subdomains, example1.MyDomain.com example2.MyDomain.com I want to create a third nodejs server that will listen on port say 3000 and route requests to ports 4000 and 5000 depending on the subdomain accessed. example1.MyDomain.com will be routed to MyDomain.com:4000 and example2.MyDomain.com will be routed to MyDomain.com:5000

could not find an example that addresses port numbers except for ngnix I also tried using proxy middleware but the examples show how to route according to the suffix after the .com and that is not what I need. Thanks for any help, Amnon

  • This sounds like a reverse proxy with domain based handling. I can recomend NGINX for that. – Marc Dec 21 '21 at 14:40

1 Answers1

2

I highly recommend you to use one of the popular proxies/load balancers for that Nginx, HAProxy, Envoy, Traefik.

If you want to do it specifically with node.js you will need create proxy server on your own,but that is not a good idea because the apps mention above already have that functionality and they are built specifically for that use case

David
  • 734
  • 5
  • 10