Support #356
Running Node.js and Apache Together using Mod_Proxy
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¶
- Apache server running on port 80
- Node.js server already running on port 3000
- Debian Wheezy 7
- 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¶
Updated by Daniel Curtis over 10 years ago
- Description updated (diff)
- Status changed from Resolved to Closed
Updated by Daniel Curtis almost 10 years ago
- Project changed from 86 to GNU/Linux Administration
- Category set to Node.js