Can I run Apache and Node.js on the same Linode?

Linode Staff

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?

3 Replies

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.

https://stackoverflow.com/questions/9831594/apache-and-node-js-on-the-same-server?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

https://coderwall.com/p/hqamtg/run-node-and-apache-sites-from-one-ip

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:

https://httpd.apache.org/docs/2.2/mod/mod_proxy.html

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 mod_proxy

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 ProxyPass and 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 http://localhost:4567

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct