简体   繁体   中英

node api for multiple apache virtual hosts

I am hosting multiple apache2 virtual hosts from one Debian ip address. I want to build a brain for all these different websites in node.js to handle server side operations like firebase authentication and server side functions. The websites are located under:

/var/www/website.one /var/www/website.two /var/www/website.three

is there a way to keep all these websites static while calling on the localhosted node express app for all the shared backend operations? The node app is located:

/var/www/brain/

if so, how would i call it. i have it running on localhost kept alive with pm2. or do i need to run multiple node express apps and forward my different ips to them?

I'm much more familiar how to do this in nginx but this should be a good example:
You'll want to use a proxy in Apache to direct your virtual hosts to a backend service. So let's say you're going to run your Node app on port 8000 (which you can do with pm2, that's fine). Each of your virtual host Apache blocks would contain something to the effect of:

ProxyRequests on ProxyPass / ProxyPass / http://localhost:8000/

This would proxy your root in the virtual host directly to your Node app. Adjust as necessary if you only want part of your application proxied (say for ex: you want to make requests to /data which is your Node app, your ProxyPass var would look like ProxyPass /data .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM