node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

QUESTION | Single port route to different services #18

Open lat94 opened this issue 5 years ago • 1 comments
trafficstars

My question is: is http-proxy capable of routing all requests from the 80 to another services based on the url? If a request comes at the port 80 with that url localhost:80/route1 I want to redirect it to the service at localhost:3001 If a request comes at the port 80 with that url localhost:80/another-route I want to redirect it to the service at localhost:3002 And so on.. To summarize it: I want to expose 1 port(80), and then route the request to other services based on the URL pattern from the request.

lat94 avatar Sep 08 '20 16:09 lat94

That can be done with a little routing on top of this, I do it using express.Router, here's an example that includes that (and some other stuff you probably don't need, just look for the /app1 route), and a blog post about it: https://gist.github.com/Jimbly/d996bd8c80ae1a376a0b

Jimbly avatar Dec 07 '21 01:12 Jimbly