I'm trying to do some testing with a legacy application that relies on subdomains for clients. So in the real application, you could go to:
clienta.domain.com
And it will open a specific area for Client A.
With EC2, I'm trying to get the application to work only using the Public DNS address which looks similar to this:
ec2-123-123-123-123.compute-1.amazonaws.com
The problem is, setting up my vhosts (like this post), works fine for the main Public DNS address, but will not work with a subdomain.
clienta.ec2-123-123-123-123.compute-1.amazonaws.com => DOES NOT WORK
I imagine this is because a DNS CNAME record must also be created? I obviously do not own amazonaws.com so do not have the ability to do that.
Here is the vhost setup:
NameVirtualHost *:80
# Primary domain
<VirtualHost *:80>
DocumentRoot "/var/www/vhosts/myapp"
ServerName ec2-123-123-123-123.compute-1.amazonaws.com
<Directory "/var/www/vhosts/myapp">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Wildcard Sub Domains
<VirtualHost *:80>
DocumentRoot "/var/www/vhosts/myapp"
ServerName clients.ec2-123-123-123-123.compute-1.amazonaws.com
ServerAlias *.ec2-123-123-123-123.compute-1.amazonaws.com
<Directory "/var/www/vhosts/myapp">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TL;DR; Without messing with DNS, is there a simple way to use subdomains with the Amazon EC2 Public DNS Address?
NOTE: I'm trying to avoid adding records to our DNS that will only be used for a short time.
UPDATE
If I must use my own domain, how can I work around two subdomains? For example, if I create staging.mydomain.com to point to the EC2 instance, now how would I access clienta.staging.mydomain.com?