Search code examples
node.jsmongodbloopbackjsloopback

How to run multiple independent Loopback applications in a VPS server?


If we have several mobile apps with different Restful web services based on LoopBack and MongoDB how could we run these projects in same time in VPS to address mobile apps and web apps to connect and uses services.

Update

It is not important that all web services using one port its important that we can address them in different addressees something like:

http://82.25.14.23/App1/api/Rerification
http://82.25.14.23/testapp2/api/registration
http://82.25.14.23/PazarWebApp/api/catagories

Solution

  • As guys said this is mostly server related topic but waht you need to do is that :

    1) each application should be run in different port number (3001, 3002, 3003)
    2) map each address to a virtual server in appache or Nginx
    
    <VirtualHost *:80>
        ServerName App1.yourdomain.com
        ProxyRequests Off
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
    
        ProxyPass / http://localhost:3001/
        ProxyPassReverse / http://localhost:3001
        ProxyPreserveHost on
    </VirtualHost>
    

    So the app running at port 3001 will be mapped at App1.yourdomain.com

    Subdomains are better than directory names.