Subdomain pointing to EC2 instance while domain is on S3 - amazon-web-services

I have a root domain like example.com. It's now hosted on Amazon S3. For that I followed this tutorial:
http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html
What would I have to do to have a subdomain like client.example.com to point to a EC2 instance?
client.example.com => ec2-XXX.us-west-2.compute.amazonaws.com
Is there like a tutorial out there explaining the steps?

Two simple steps:
You would just need to add a new 'A' record to assign the ec2 ip address to that subdomain in your amazon route 53 dns (or whatever dns provider you are using) - very simple to do. Step one will have requests for that sub-domain routed to the ec2 instance.
Step 2 is to tell the web server you are running, when it receives a requests for that sub-domaain, what website should it serve up to the user - you do this by 'binding' the name to the directory/location thast has the website on your ec2 instance.

You may also want to read over the following from AWS
http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-ec2-instance.html
It would also be better practice to assign your EC2 instance an Elastic IP address then forward requests to that IP.
We recommend that you also create an Elastic IP address and associate
it with your Amazon EC2 instance. An Elastic IP address ensures that
the IP address of your Amazon EC2 instance will never change.

Related

How to run a ec2 instance as subdomain in siteground?

I have a Wordpress website with a GoDaddy domain being hosted on SiteGround using the nameservers. I am looking to switch to a React App which is currently running on an EC2 instance in AWS. I want to run the ec2 instance (aka the react app) on a subdomain like beta.domain.com inside SiteGround while still keeping the Wordpress website since its a part of my business. I tried creating a subdomain in SiteGround and then pointed it to my EC2 instance elastic IP (the public ipv4) using an A record but it is showing "This site can't be reached" error once I go to beta.domain.com.
What am I doing wrong? How do I run the EC2 instance in a subdomain hosted in SiteGround?
EDIT
Thank you, everyone, for your help. The problem was the SSL certificate for the HTTPS. The website wasn't coming on due to the HTTPS setup on the Nginx on the EC2 instance. After I put in the details of the certificate it runs properly with just the A record.
Any public address in the AWS environment are never accessible from outside the security groups. Even if you try to ssh from your own machine and if it is not in the inbound rule of the security group of your EC2 instance. I feel there are 3 ways out here.
1.) Adding an all traffic rule in your EC2 Security group inbound rule. This is not recommended as it opens all traffic to your machine.(additional tip: set up secure ssh key with the machine)
2.) Use an ELB to route traffic to your EC2 instance. ELB will provide you with a DNS record which can be used an a CNAME in godaddy(Point 3 shows how to map it as a A record in GoDaddy)
3.) Using Route 53 Hosted Zones - You could delegate your DNS to be managed by AWS Route 53. This way all traffic will be routed to your machine by AWS R53.
Another tip: Elastic IP can also be used which are like permanent static IP Addresses accessible from across internet. This provided a secure communication method to your instances.
Let me know what could be the favorable solution for you. I could help you out further
If you have registered your domain name with Goaddy, you can create subdomain in Godaddy as CNAME and point it to static IP address of your ec2 instance. Here is a link to guide you.
Also your main domain name will point to your Wordpress website on SiteGround.
Now that you have EC2 instance, you can also run a wordpress site on that instance if you like.

Linking subdomain on bigrock to Amazon EC2 instance

I have a domain name hosted on bigrock.in pointed to an Amazon EC2 instance using Route 53. The four nameservers generated are placed in bigrock and it is working fine.
Now I have created a subdomain of the domain in bigrock and I want it to point to my application in another EC2 instance in another AWS account. Is this possible?
Yes. The AWS account that is currently controlling your domain name with Route 53 must be used, but it can be pointed to anything on the Internet.
Steps:
In the AWS account with the "other" EC2 instance, create an Elastic IP Address and assign it to the EC2 instance. This will ensure that its IP address does not change when the instance is stopped and started.
In your existing Route 53 configuration (in the original account), create a Record Set for the sub-domain (eg images.example.com) of type A and enter the Elastic IP Address as the value.
Once you have set the nameserver for your domain to point to Route53, you no longer need to control the subdomains from bigrock services. Just add them to your Route53 dashboard, and they'll be reflected live.

How can I serve multiple sub-domains using a single Elastic IP Address in AWS using Route 53?

I have a single Elastic IP address on AWS and I want to use that IP address to route traffic to multiple distinct EC2 instances based on the sub-domain. Basically, in the same manner as virtual hosts in an Apache httpd server. For example:
example.com - ELB: xxx.xxx.xxx.xxx
test.example.com points to EC2 Instance ID 1
build.example.com point to EC2 Instance ID 2
All traffic for each of the domains would go to xxx.xxx.xxx.xxx and then based on the sub-domain name Route 53 would send traffic to the correct instance.
I've been through the documentation for Route 53 and I can't see how this is done. I also looked at Amazon ELB but was unsure if that would work.
Does anyone know how to set this up just using the AWS tools (Route 53 and/or ELB)? I'd rather not have to script it or use a reverse proxy if I can avoid it.
Any ideas or help would be great. Thanks in advance.
You don't need an elastic ip for each server. Each server already comes with an IP, so you can use that (if you actually want to address servers by ip address) - but what you likely should be doing is setting up a cname on your domain for each server, and then addressing the server's by the dns name, not by the ip address.
i.e.:
server1.example.com
server2.example.com
server3.example.com
etc
You don't need to use any EIP's.
Maybe you could explain better why you think all the traffic needs to go thru a single IP address?
I can't say for sure why AWS limits you to just 5 EIPs, but I am pretty sure its because if you find out you need hundreds of EIP's then you are probably doing it wrong - and forcing you to request more than 5 gives them the ability to open up a discussion with you and help you do it a better way.
You'll need 1 Elastic IP address for each distinct EC2 instance that you want to redirect traffic to.
Create your CNAME or ALIAS record for example.com and point it to your ELB.
For each distinct EC2 instance that you need a sub-domain for, do the following:
Allocate an Elastic IP address.
Assign that Elastic IP address to the EC2 instance.
Create an A record in Route 53 pointing subdomain.example.com to that Elastic IP address.
Note: Since your EC2 instances need to be accessed directly, they will need to reside inside a public subnet.

Creating subdomain in amazon ec2 instance

I have the instance ec2-xx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com. It is running a bitnami lamp stack.
How do I create a subdomain for this like subDomain.ec2-xx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com?
Is it possible to do such this or should I purchase a domain first?
Thanks
You cannot manage AWS domains. You need to have your own domain first and use Route 53 or any other DNS provider to create an A record pointing to this specific EC2 instance.
Before creating the A record however you will need to provision an Elastic IP and assign it to your EC2. Please keep in mind that every account starts out with only 5 Elastic IPs and if you need more you will have to get in touch with Amazon for approval.

How redirect a domain to Amazon EC2 Machine?

I'm using EC2 of Amazon to host a website built in JSP :
http://ec2-50-17-144-64.compute-1.amazonaws.com:8080/p2p
And I bought this domain:
www.p2pbrasil.com
How can I redirect www.p2pbrasil.com to my website in Amazon EC2 ?
When someone type www.p2pbrasil.com it redirects to http://ec2-50-17-144-64.compute-1.amazonaws.com:8080/p2p ?
You need to do two things
In the Amazon Web Service admin panel, create an elastic IP in the same region as your instance and associate that IP with your that instance (IPs cost nothing while they are associated with an instance, but do cost if not).
Add a A record to the DNS record of your domain mapping the domain to the elastic IP address assigned in (1). Your domain provide should either give you some way to set the A record (the IP address), or it will give you a way to edit the nameservers of your domain.
If they do not allow you to set the A record directly, find a DNS management service like ZoneEdit, register your domain as a zone there and ZoneEdit will give you the nameservers to enter in the admin panel of your domain provider. You can then add the A record for the domain in ZoneEdit.
I only mention ZoneEdit because the basic service is free, you could also use Amazon route 53 or a similar pay-for service, if you preferred.
Create an Elastic IP on the AWS Panel, then associate it to your instance.
Then use a DNS management service to add your domain and Ip address (Elastic IP), then on the domain provider panel add the DNS provided from the DNS management service.
I recommend EntryDNS which is actually free.
As you have your server on AWS best option is to use Route53 hosted zone.By doing this you can manage all your DNS entries using AWS. In future if you plan to use ELB's for your application, you can various traffic routing options using Route53.
Create Hosted Zone and get the name servers.
Replace current name servers with AWS nameservers from your Domain registrars DNS entries.
Create an A record in AWS hosted zone and give your servers IP (Elastic IP) as value.
For detailed instruction, you can follow this blog post. Mapping Domain Name to EC2 Server
Assuming this is a hobby website and your domain registrar isn't AWS.
If your registrar (for example godaddy.com) provides a DNS manager you simply need to add a CNAME record for www that points to the aws public DNS record for your instance. For example ec2-50-17-144-64.compute-1.amazonaws.com
This will make http://www.p2pbrasil.com display the same content as http://ec2-50-17-144-64.compute-1.amazonaws.com
Doing it this way you don't have to pay for an elastic IP, which is a dedicated resource. Your IP on your ec2 instance shouldn't change but could if you restart your instance.
Put the public IP from your EC2 instance as an A name to your root domain in Route 53 hosted zone.
This change might take some time.