First, please note that this is a stupid way to solve the problem at hand, namely getting multiple applications, developed with full-stack frameworks, running on the same server.
This should be considered a last resort as it uses the framework's built-in servers, which is intended for development only. The trick here is to use Apache's mod_proxy to reverse-proxy the development server into the Apache URL space.
Setup
First of course, you need the relevant software installed:
sudo apt-get install apache2-mpm-prefork
sudo a2enmod proxy_http
I'm going to assume a project running on its own server on port 3000 that you want visible at http://server/app/
. Of course, if you have multiple projects, they will all need to be on separate ports.
To connect this server to the URL, edit /etc/apache2/sites-enabled/000-default
and at the bottom of the
<Virtualhost>
section, add this:
<Proxy *> Allow from all </Proxy> ProxyPass /app/ http://localhost:3000/
Redirects and Links
Of course, any links within your system will have to take the new URL into account. For example, a link like this
<a href="/controller/view">
will have to become:
<a href="/app/controller/view">
For URLs you generate yourself, fixing this isn't too bad (especially if you develop with a configurable base URL in mind from the start). The problem comes from URLs your framework builds for you. This can also include any redirects that are generated.
The way to solve this depends on the framework. It may be as easy as setting a base URL somewhere in a configuration file. It may also be a huge hassle.
In theory, Apache can rewrite these URLs for you automatically with the ProxyPassReverse
directives from mod_proxy. I haven't been able to get this to work properly myself: let me know if you do.