Ubuntu – Where to start? Multiple Websites, same IP and port, same SSL, on Apache 2.4, Ubuntu, EC2, behind AWS ELB

amazon-elbamazon-web-servicesapache-2.4sslUbuntu

Current Situation: My company runs a number of individual EC2 instances hosting unique websites using multiple subdomains off of a common top-level domain. (abc.foo.com, and def.foo.com, for example).

Each of these websites is currently performing the SSL offload independently, but using a common cert. We currently run Ubuntu LTSs, including 10.04, 12.04, and 14.04, all running Apache (2.2 or 2.4).

Our systems use VHost files to establish the sites on the instances, and on the few instances where we have multiple sites running, we use multiple VHosts with different ports and docroots (:80 /var/www/abc for abc.foo.com, and :81 /var/www/def for def.foo.com). All of these instance run using <2% of available resources, and all from the same monolithic codebase.

Desired End State: I want to consolidate all of the small unused servers into a single Ubuntu 14.04 server using Apache 2.4, and run all of those sites off of a Single ELB in AWS, fronted and cached by CloudFront, where the SSL offload happens on the ELB.

Problem/Question: I have no idea how to go about doing this… Is there a way to have multiple sites using the same IP and port that can be fronted using the ELB? Since Apache wont boot with VHosts that have the same IP/port, I don't even know where to start, and some of my basic Google searches don't turn up any examples or discussions of this type of scenario.

Best Answer

You can have different VHosts on Apache, all listening to the same IP and Port. That's how huge hosting providers work: they have a big Apache server and lots of domains using VHosts on port 80 and the same IP.

I would create a virtual host for every subdomain, all on port 80, and put the specific configurations for each one on a VHost configuration block. The Virtual Host Guides from Apache and DigitalOcean are very good and detailed, I think you can learn from them and put it to work.

It's not hard, you can do it.