Marc Godard Marc Godard - 1 year ago 163
Node.js Question

FeathersJS on server with multiple hosts

I have a VPS that runs apache on with many domains (all same IP), but I want to start running nodeJS/feathersJS for some of my sites.

I can't seem to figure out how to run multiple instances other than with different ports. However, all the feathers sites are available to all the others provided you add the port (even sites running an apache site).

Is there an easy way to limit to show feathersjs site, and to still use apache?

IS there something I am missing?

I am new to node and transitioning from a PHP person to a nodeJS person... so please forgive my ignorance.

I found some non-feathersJS modules that I could figure out to use, but there has to be an easier way then modifying feathersJS... no?

*Edit I found the apache proxy solution already and implemented it. However, now I need to make sure that the port that runs node isn't used on my other domains. now using apache proxy stuff run localhost:3030 but so does

Is there a way to limit this?

I found some libraries that do this for node, but none that seem to be nicely implemented in feathersJS.

*edit again I think the mentioned vHost feathers thing is what I am looking for, will update when i test this.

Answer Source

There is different ways to go about it but one way would be to use mod_proxy for Apache. In your domain configuration you'd then point to the port where the application you want is running on:

ProxyPass /
ProxyPassReverse /

While putting an Apache or NginX proxy in front of a Node application (and to serve static content) is usually a good idea for higher traffic sites, for smaller projects you can also just use Node without having to worry about Apache. To host different apps on different domains, you can use the vhost Express middleware. An example how to set it up with Feathers can be found here.