Project

General

Profile

Support #356

Running Node.js and Apache Together using Mod_Proxy

Added by Daniel Curtis over 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Node.js
Target version:
-
Start date:
04/03/2014
Due date:
% Done:

100%

Estimated time:
0.50 h
Spent time:

Description

Lets say that you want to experiment with Node.js or you want to start to leverage its awesome features but you don’t want to throw away all of your existing Apache compatible website. This tutorial will show you how to configure your existing Apache server to forward requests for a specific folder to Node.js. I’m going to set it up so Node.js handles the /node/ folder and Apache handles everything else.

Assumptions and My Setup

  1. Apache server running on port 80
  2. Node.js server already running on port 3000
  3. Debian Wheezy 7
  4. The site is example.com

Configure the Proxy

Enable the modproxy and modproxyhtml Apache modules. They should be available by default so just enable them with the a2enmod command.

sudo a2enmod proxy
sudo a2enmod proxy_http

Now edit your virtual host file (/etc/apache2/sites-available/example.com.conf) to have reverse proxy settings. Within the node, add the following:

ServerName example.com
ServerAlias www.example.com
ProxyRequests off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://node.example.com:3000/
ProxyPassReverse http://node.example.com:3000/
</Location>

Save that and restart apache with:

sudo service apache2 restart

Resources

#1

Updated by Daniel Curtis over 10 years ago

  • Description updated (diff)
#2

Updated by Daniel Curtis over 10 years ago

  • Description updated (diff)
  • Status changed from Resolved to Closed
#3

Updated by Daniel Curtis almost 10 years ago

  • Project changed from 86 to GNU/Linux Administration
  • Category set to Node.js

Also available in: Atom PDF