0

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.

  • 1
    This is pretty simple, and you do essentially exactly what you described. What is the problem you are having with it? – Michael Hampton Oct 17 '14 at 15:40
  • Perhaps you need to review the apache documentation on virtualhosts and also search this site for virtualhosts, you'll find lots of questions where people are doing exactly what you think can't be done. – Iain Oct 17 '14 at 15:58
0

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.

  • So, would it be better to use a single VHost file with multiple <VirtualHost *:80> ... </VirtualHost> entries, or multiple VHost files with their own entires? Or it that just dealers choice? – HeavyObjectLifter Oct 17 '14 at 16:47
  • Either approach would work - it's just a matter of preference. We run roughly a dozen vhosts in EC2 using a single apache include file, but that's mainly because our vhosts are all very similar and the file is templated and generated automatically using Ansible. – Bruce P Oct 17 '14 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.