Namecheap
Once you have these prerequisites, you can follow the steps below to deploy your domain and subdomain on AWS Route 53.
example.com
) and click “Create hosted zone”.First we will create a record set for the root domain that points to GitHub Pages.
Click on the hosted zone you just created.
Click on “Create record set”.
Leave the “Name” field blank to create a record set for the root domain.
Select “A - IPv4 address” for the “Type” field.
In the “Value” field, enter the IP addresses below. These are the IP addresses for GitHub Pages.
185.199.108.153
,185.199.109.153
,185.199.110.153
,185.199.111.153
Click “Create” to create the record set.
Next, we will create a CNAME record set for the www
subdomain that also points to GitHub Pages.
www
in the “Name” field.username.github.io
).Now we will create a record set for the subdomain that points to the EC2 instance.
api
) in the “Name” field.We will now want to make sure our domain is HTTPS secure. To do this, we will use Caddy to reverse proxy our EC2 instance.
SSH into your EC2 instance.
Install Caddy by running the following commands:
sudo apt update
sudo apt install caddy
Create a Caddyfile in the /etc/caddy
directory with the following configuration:
api.example.com {
reverse_proxy localhost:3000
}
Be sure to replace api.example.com
with your subdomain and localhost:3000
with the address of your API server.
Restart Caddy to apply the changes:
sudo systemctl restart caddy
Finally, you will need to update the DNS servers on Namecheap to point to the AWS Route 53 name servers.
In the AWS Route 53 console, click on the hosted zone you created.
Copy the four name servers listed under “Name servers”, or NS
records. These will look something like:
ns-13.awsdns-2.com.
,ns-35.awsdns-4.net.
,ns-57.awsdns-6.org.
,ns-79.awsdns-8.co.uk.
Log in to your Namecheap account and navigate to the domain management page.
Click on “Domain” in the left-hand menu and select your domain.
Click on “Nameservers” and select “Custom DNS”.
Paste the AWS Route 53 name servers into the four fields provided.
Click the checkmark to save the changes.
It can take time for the steps above to take effect. If you encounter any issues, here are some common troubleshooting steps:
If your domain is not connecting to GitHub Pages, make sure you have created a CNAME file in your GitHub Pages repository with your domain name (e.g., example.com
).
echo "example.com" > CNAME
Another common issue is not setting the homepage
field in your package.json
file to your GitHub Pages URL. For example:
"homepage": "https://username.github.io/repo-name"
And, be sure to run npm run deploy
to deploy your site to GitHub Pages.
If you encounter a CNAME conflict error when creating the record set for the www
subdomain, you may need to delete any existing CNAME records for the www
subdomain in the hosted zone.
It may take some time for the DNS changes to propagate. You can use tools like DNS Checker to check the status of your DNS records. It may take up to 48 hours for the changes to fully propagate.