Subdomain using AWS Route 53, load balancer, EC2, Apache
I havent worked with much AWS, but the general way of doing it will be as follows.
Let say currently you have example.com
hosted in Route53, so Route53 is the authoritative nameserver for your example.com
zone. Now if you want a subdomain called client.example.com
which again needs to point to the same IP address where example.com
.
So in that case create a CNAME record where example.com
will be canonical name and client.example.com
will be alias record.
Once this is done now example.com
and client.example.com
will both resolve to the same IP address i.e to the Load balancer.
If you prefer to share the same DocumentRoot
of example.com
to client.example.com
you have noting extra to do. But if you want to serve different content then create a Name-Based Virtual host in Apache.
Update
As you want both demo.example.com
and example.com
to serve different contents you have to create a Name-Based virtual host in Apache.
The configuration will be looking like
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/main
</VirtualHost>
<VirtualHost *:80>
ServerName demo.example.com
DocumentRoot /var/www/content
</VirtualHost>
The above configuration will serve file from /var/www/main
if request is for http://example.com
or http://www.example.com
. And it will serve files from /var/www/content
if the request is for http://demo.example.com
.