Aws-Ec2, How to Set Multiple Public Sites with Just One Instance

How Can I Host Multiple Websites Under One Amazon EC2 Instance?

You need to fix your httpd.conf file and make sure to include

NameVirtualHost *:80

once done make sure to restart apache and it should be ok

One Website to be connected with Multiple EC2 Instance?

If you are migrating from a more conventional hosting to a cloud provider but you don't adopt a cloud architecture, you are missing out many of the benefits of the cloud.

In general, for a highly available, highly scalable web application, having shared data locally is an anti-pattern.

A modern web application would separate state (storage) from processing. Ideally your instance would hold only configuration and temporary data. For the database, assuming you are using a relational database, you would start a RDS instance. For the files, if they are mainly things like images and static content, you would probably use The Simple Storage Service, S3.

Your EC2 instance would connect to the RDS database and S3. Since the data is not local to the instance anymore, you can easily have multiple instances all using the same storage.

Your EC2 instances could be configured with autoscaling, so AWS would automatically add or remove instances responding to the real traffic you are seeing.

If you have complex storage needs and S3 is not enough for the file layer (and for most applications S3 should suffice), you can take a look at the Elastic File System.

AWS Host Multiple Domains On One EC2 Instance

I can see from the whois greyspace.io and tlsbasebll.com are pointed to Route53 servers, but they're not answering my queries. Look at the hosted zones in Route 53 and verify that the NS servers specified there are the ones from Amazon and line up with what you have in DNS. It's pretty easy to swap them or get them wrong when you're doing multiple domains.

$ whois greyspace.io

Domain : greyspace.io
Status : Live
Expiry : 2017-11-25

NS 1 : ns-1566.awsdns-03.co.uk
NS 2 : ns-1297.awsdns-34.org
NS 3 : ns-1021.awsdns-63.net
NS 4 : ns-343.awsdns-42.com
$ dig @ns-343.awsdns-42.com greyspace.io -t soa

; <<>> DiG 9.8.3-P1 <<>> @ns-343.awsdns-42.com greyspace.io -t soa
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 27079
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;greyspace.io. IN SOA

;; Query time: 26 msec
;; SERVER: 205.251.193.87#53(205.251.193.87)
;; WHEN: Sat Dec 24 10:19:01 2016
;; MSG SIZE rcvd: 30

Based on your comment below, it sounds like you registered these domains with amazon, and then recreated the hosted zone a few times. Let's look a little closer at what that really looks like for, say, greyspace.io:

  1. register with amazon

    1. as dns provider, amazon automatically creates a hosted zone to serve the
      records associated with your domain, which generates the names of
      nameservers willing to answer queries for that domain
    2. as a registrar amazon saves the greyspace registration data within the
      .io registry, along with dns glue records that point requests for the
      domain to the AWS Route53 servers from step 1

Now the domain's dns hsoted zone is "live", in that the whois data points to it.


  1. you delete and recreate the dns hosted zone. Upon deletion, the listed
    nameservers aren't willing to answer these queries anymore, but they're
    still listed in DNS

So all you have to do is go into your domain registration and update the whois
listed nameservers to point to the new ones you got when you recreated the hosted zone.

On an unrelated note, why do you have this in here twice?

<VirtualHost *:80>
ServerName default:80
DocumentRoot /var/www/html/brentrichison.com
ServerAdmin brent@brentrichison.com
ErrorLog /var/www/html/logs/error.log
</VirtualHost>

<VirtualHost *:80>
ServerName brentrichison.com
DocumentRoot /var/www/html/brentrichison.com
</VirtualHost>

2 sites with the same docroot? I'm confused. Aren't those actually the same site?

How to run more than one app on one instance of EC2

There are multiple ways to go about it.

Different Ports

You could run each Node.js process on a different port and simply open the ports to the world. However, your URLs would need a port on the end of the hostname for each project. yoururl.com:8080/ would technically work, but probably not what you're looking for.

Multiple IP Addresses

You could use multiple IP addresses on one EC2 instance, however, they come with an additional cost of about $3.65 a month each. So if you have 10 different domains you want to host on once instance then that's over $30 a month extra in hosting fees.

On the flip side, any domain using SSL needs it's own IP address.

Also, there are limits to the number of IP addresses you can assign to an instance and the smaller the instance, the less IP addresses you get.

The number of IP addresses that you can assign varies by instance type. Small instances can accommodate up to 8 IP addresses (across 2 elastic network interfaces) whereas High-Memory Quadruple Extra Large and Cluster Computer Eight Extra Large instances can be assigned up to 240 IP addresses (across 8 elastic network interfaces). For more information about IP address and elastic network interface limits, go to Instance Families and Types in the Amazon EC2 User Guide.

Express Vhosts

Express comes with virtual host functionality. You can run multiple domains under one Node.js/Express server and setup routes based on domain name. vhost under Express enables this.

Reverse Proxy

You can setup Nginx in front of multiple application servers. This has the most flexibility. You can have one Node.js process per domain which allows you to do updates and restarts on one domain at a time. It also allows you to host applications servers such as Apache/PHP under the same EC2 instance along side your Node.js process.

With Nginx acting as a reverse proxy you could also host different application servers under the same domain, but serving different paths.

For instance, Node.js could serve the main root path of a domain but you could setup the /blog/ path to go to a Apache/PHP/Wordpress setup on the same EC2 instance.



Related Topics



Leave a reply



Submit