Search code examples
javascriptnode.jsproxynode-http-proxynodejitsu

What is the point of using a proxy server such as node-http-proxy for a node app with a single app on one port?


I'm exploring using the node-http-proxy proxy server so that I can have our proxy server on port 80 forward requests to our app server on port 8000. However, I'm a little confused as to why this is a good idea, and what exactly this set up would protect against security-wise.

The note-http-proxy documentation discusses a lot about using it as a way to forward requests to an app with multiple ports or ip addresses. This obviously would be very useful, particularly with a basic round-robin load balancer strategy. However, we only have one app on one port, so there is no need for us to do this.

If there is an important security reason why we should be using this proxy-server, then I'd love to know what types of attacks it protects against. Also, we're using socket.io, so if there is something that the proxy does to help the websocket server scale up, I'd like to understand that as well. We're having trouble figuring out how to run our app without sudo (since all ports below 1024 require root access), so if there really is no good reason to use a proxy server at this point, we're just going to scrap at. If anyone knows how to run this app with the proxy server on port 80 without root access, that'd be very helpful as well. Thanks!


Solution

  • The reasons for running a reverse proxy are:

    • You have limited IP ports open and need to run many Node services each of which needs it's own port
    • Your back-end service does not support HTTPS but you need it (e.g. Derby)
    • To add some other feature to the request that cannot be easily done with the back end such as adding Basic Authentication or some form of common logging/auditing
    • To enforce an addition or change to outgoing responses common across several back end services
    • To provide a load-balancing service

    Unless your needs are quite simple, it would be better to use a dedicated proxy such as HAproxy since node-http-proxy is rather simplistic.