Edit:// Also Digita Ocean $5 VPS is cheap to play with Node on, or even use a Vagrant machine.
Obviously I could pay for other hardware but I don't want to do that.
"It's easy, just install Node." funny.
Essentially you setup nginx to listen on port 80, Apache to listen on another port (say, 8080) and node to listen on a different port (say, 8081). Then have your nginx config differentiate between the two:
upstream apache {
server 127.0.0.1:8080;
}
upstream nodeapp {
server 127.0.0.1:8081;
}
server {
listen 80;
server_name myphpapp.example.com;
location / {
proxy_pass http://apache;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name mynodeapp.example.com;
location / {
proxy_pass http://nodeapp;
proxy_set_header Host $host;
}
}
IMO this gets a little easier to think about if you substitute your Apache -(mod_php)-> PHP setup for Nginx -(fastcgi)-> php-fpm - handing off to an appserver rather than a webserver.I've considered reverse-proxying entirely within Apache to avoid adding ngnix another layer. But this really hinders some of the advantages of node which makes me wonder if it's worth even doing. It seems like node is best when it can handle the requests directly.
Your advice here is pretty much the most common answer.
What makes you believe that?