Bringing multiple Virtual Hosts within the same URL space with Apache

Our team has been working on a rather large and complex web application project for the past couple of years. Now, nearing its completion, we are challenged with the necessity to host, deploy and support the ready product. On one hand side, we want to retain control over the code base for each customer separately, i.e. be able to introduce individual installations which coexist but have different source code versions. On the other side, we want to offer the platform to everyone under a common URL namespace and be sure, that every user is routed to their own virtual host.

Main Challenges

  • Host a large number of virtual hosts (e.g. more than 1000), each with its own code base, source code revision, database and settings;
  • Introduce individual customer identification and authorization;
  • Secure the virtual hosts serving the actual application and isolate them from the outside World through a firewall;
  • Use the above information to route each customer to the correct virtual host, representing their individual installation;
  • Bring everything transparently under the same URL namespace, advertising a single URL to everyone for product access.

The Approach

The basic idea was to authenticate each web user for the purposes of giving them access to the application. Then use this information to route the user’s requests to the correct virtual host, that contains their individual code base and settings. To achieve this, we decided to introduce a gateway server to handle the authentication and routing.

Continue reading “Bringing multiple Virtual Hosts within the same URL space with Apache”