Reputation: 892
I've a reverse proxy gateway that works perfectly using express-http-proxy when on the cloud.
However, I've been trying to get the system working on localhost so that I can develop faster.
I was hoping I could set up:
Gateway on localhost:3001
API on localhost:3002
MobileWeb on localhost:3003
All the apps seem to be working on their respective ports on localhost, however when requests that pass through express-http-proxy get a 504 timeout. I tried reverse proxied the requests to other sites on the internet and found that it worked, however proxying things to localhost:3002, or localhost:3003 didn't get anything forwarded to them.
app.get('/', expressProxy('localhost:3003', {
https: false, //don't use https on localhost
forwardPath: function(req, res){
return 'SplashPage';
}
}));
Any suggestions? Is this something that isn't possible with the express-http-proxy package?
Upvotes: 1
Views: 850
Reputation: 892
It seems the issue was with express-http-proxy and it's tendency to strip the port off of the proxied target and replace it with :80
It would be a great fix for that package to incorporate the option of forwardPort:
Solution: I stopped using npm's express-http-proxy and swapped it out for npm's http-proxy. Seems to be much more robust and certainly has no issues adding the port.
Upvotes: 0