How to run a ec2 instance as subdomain in siteground? - amazon-web-services

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.

Related

Point subdomain to EC2 instance?

I bought a domain with Google. I set up custom name servers to point the domain to Zeit.
Custom Name Servers
f.zeit-world.net
d.zeit-world.com
b.zeit-world.org
a.zeit-world.co.uk
Zeit controls the domain. I have spun up an EC2 instance with an elastic IP. I want to be able to point api.mydomain.com to the elastic IP using a CNAME.
added fake elastic ip just for example
now dns add mydomain.com api CNAME 194.119.279.121
I am not sure why it's not being resolved, obviously, I am missing some information. The URL api.mydomain.com just hangs.
Any insight into what step I am missing?

Route53 - DNS resolution to a specific port on an EC2 instance

I have a website that I have hosted on an EC2 instance that runs on port 3000. (e.g. 3.27.83.19:3000 - assuming the IP address of the EC2 instance is 3.27.83.19)
I have a domain that I have already bought mydomain.com through AWS that I already see in Hosted Zones.
How can I set-up Route53 so that when someone hits "mydomain.com", it takes them to 3.27.83.19:3000 rather than 3.27.83.19
Thanks!
point domain to instance ip
To point example.com to 3.27.83.19 you simply need to create an A record in route53
point domain to load balancer
To access the website running port 3000 on an EC2 instance through https://example.com, you need a service that accepts traffic on https://example.com and then forward the traffic to the EC2 instance on port 3000. You can easily do it with an AWS application load balancer. I like this approach.
There are many benefits using an application load balancer. The important one is that you can configure the SSL certificate easily. The application load balancer also supports host based routing which allows you to host multiple websites.
If you are looking for less expensive solutions, you can also go for setting up an nginx proxy inside the ec2 instance. I personally don't like this approach because you will need to configure SSL at the application level.
https://aws.amazon.com/premiumsupport/knowledge-center/public-load-balancer-private-ec2/
Hope this helps.

Pointing a domain to securely connect to an ec2 instance running a python app

Say I have an AWS ec2 instance that is running a python application on a certain port say 8000. Also imagine I have a domain name say www.abcd.com that I own. What does it take to make my website use https and securely redirect to the app on my ec2 that is listening on port 8000? Is this even possible to do or do I need something like nginx in between?
Firstly you will need to ensure that your EC2 is in a public subnet with a public IP, it will also need its security group open on whatever port you are hitting it on (8000). At this point you should be able to hit your application on public ip:port.
Now if you want to do the above while using a domain you will want to use AWS's Route 53 service. From this you can create a DNS routing using your domain. You will want to create a route from: application.example.com to your instances public ip. After doing so you should be able to visit: application.example.com and hit your application. In doing the following it is possible now to make your EC2 instance private.
Now if you wish to include HTTPS ontop of this, the best way would be to create a public load balancer with a certificate attached, this would accept HTTPS traffic from your user, then forward that traffic over HTTP to your EC2 on a selected port (8000).
After doing this you will want to change your Route53 entry to point to your load balancer instead of directly at your EC2.
Yes, it is totally possible.
Here is step wise procedure to do it :-
you need to create hosted zone on Route-53 services of amazon
Then it use ns to connect with your domain ( wherever you have registered)
Then you need to connect your ec2 instance ip with your hosted zone
Now you can access your ec2 instances using this domain, but it will be not https
For https, you need certificate, which you can avail from aws certificate-manager
After obtaining the certificate, Follow the steps from this blog How to set up HTTPS for your domain on AWS.
NOTE:- This is just uber point, follow it and look for more insight to how you exactly do it in your case. I followed this step while deploying using elastic-beanstalk.

Subdomain pointing to EC2 instance while domain is on S3

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.

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.