Can I run Apache and Node.js on the same Linode?
I would like to run Apache and Node.js on the same Linode, but I only have a single IP address. Can this be done?
Yes this can be done. We do not have official documentation on this, but I was able to track down some information that should be useful.
These examples offer two separate ways to accomplish this using Apache's mod_proxy feature, which you can read more about at the following link:
As an aside, it would be nice to have http/https links automatically render as such on this site, instead of just plain text.
…but I only have a single IP address. Can this be done?
Rather than worrying about how to run Apache and Node side by side, you could consider proxying node.js through Apache. Here is a great article on how to do this. First you need to install
In the author's example all traffic comes to apache on port 80, but some traffic gets routed to an upstream node service using a Location directive. This is where
mod_proxy comes in…
mod_proxy allows for the addition of
ProxyPassReverse directives. These allow you to remap requests to upstream servers.
<VirtualHost *:80> ServerName local.example.com ErrorLog "/var/log/httpd/com.example.local-error_log" CustomLog "/var/log/httpd/com.example.local-access_log" common ## Here's our magic ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> # no, this closing tag is not a typo ProxyPass http://localhost:4567 # Our port goes here ProxyPassReverse http://localhost:4567 </Location> </VirtualHost>
With this setup any traffic on
<host>:80/ gets routed to a node server listening on