Host a Ghost Blog on AWS in 2023 (II) - Domain Setup

Host a Ghost Blog on AWS in 2023 (II)  - Domain Setup
Photo by Vincent Yuan @USA / Unsplash

Following the last part of installing Ghost on AWS, the website should be up and running, but the website can only be accessed by its IP address, so in this post the tutorial of setting up the domain will be shared to show that how your website can be access through its domain, such as vincentyuan.us.

Host a Ghost Blog on AWS in 2023 (Part 1) - AWS Setup
I used to share a lot of programming and data science content on the Internet along with a few friends, BulletTech is one of the websites we built to this end, and we have actually learnt a lot during peer review and discussion on those topics. This reminds me of

1 Buy Domains

Firstly, you should order an domain or a few domains if you want your Ghost website to be able to be accessed through different domains. Here are some domain providers and their links:

  • GoDaddy: https://www.godaddy.com/domains
  • Domain.com: https://www.domain.com/
  • Namecheap: https://www.namecheap.com/
  • HostGator: https://www.hostgator.com/domains
  • Yahoo Small Business: https://smallbusiness.yahoo.com/domains
  • Wix Domains: https://www.wix.com/domain/names
  • Google Domains: https://domains.google/
  • Gandi.net: https://www.gandi.net/en/domain
  • DNSimple: https://dnsimple.com/
  • Network Solutions: https://www.networksolutions.com/domain-name-registration
  • Register.com: https://www.register.com/
  • NameSilo.com: https://www.namesilo.com/
  • DreamHost: https://www.dreamhost.com/domains/
  • Hover: https://hover.com/
  • Name.com: https://www.name.com/
  • 1&1 IONOS: https://www.ionos.com/domains/domain-names

I choose Namecheap simply because it is easy to use and it is affordable. Simply search for the name that you expect and it returns available domains, in this step, simply buying the domain is enough, SSL is not mandatory as Ghost provides free SSL setup.

Domain Search

2 Set up Domain

In order to link IP to a website name, Domain Name System (DNS) comes into play! And to help audience around the globe access your website quickly, Content Delivery Network also plays an important role. So let's review what they are first!

2.1 Domain Name System

The Domain Name System (DNS) is a fundamental component of the internet that serves as a decentralized system for translating human-friendly domain names into the IP addresses that computers use to identify each other on a network. In simpler terms, DNS acts as a directory that enables users to access websites and online resources using easy-to-remember domain names (like www.example.com) instead of needing to remember complex numerical IP addresses (like 192.168.1.1).

Here's how DNS works and what it does:

Domain Names: When you type a domain name (e.g., www.google.com) into your web browser, your computer needs to know the corresponding IP address of the server hosting that website.

DNS Resolution: Your computer sends a DNS request to a DNS server (usually provided by your internet service provider). If the DNS server has the IP address for the requested domain cached, it responds with the IP address, and your computer can connect to the website.

Recursive DNS: If the DNS server doesn't have the IP address cached, it performs a recursive search. It starts by asking the root DNS servers for information about the top-level domain (like .com). The root server then refers the DNS server to the appropriate top-level domain server.

Top-Level Domain Servers: The top-level domain server knows which authoritative DNS server handles the specific domain requested (like example.com).

Authoritative DNS Server: The authoritative DNS server for the requested domain holds the IP address information for that domain. It responds to the original DNS server with the IP address.

Caching: The original DNS server caches the IP address information for a certain period. This way, if another request for the same domain comes in, it can respond more quickly without going through the entire process again.

In summary, DNS plays a crucial role in translating user-friendly domain names into the numeric IP addresses that computers need to communicate over the internet. It ensures that users can easily access websites, email servers, and other online resources without needing to remember or use numerical IP addresses.

2.2 Content Delivery Network

A Content Delivery Network (CDN) is a network of distributed servers strategically located around the world to deliver web content, such as images, videos, stylesheets, scripts, and other assets, to users more efficiently and quickly. The primary purpose of a CDN is to improve the performance, availability, and reliability of websites and web applications by reducing the distance between the user's device and the server hosting the content.

Here's how a CDN works and what it does:

Geographical Distribution: A CDN consists of multiple servers, often referred to as "edge servers," located in various geographic locations. These servers are strategically placed in data centers to ensure that they are closer to the end users.

Caching: When a user requests content from a website or web application, the CDN's edge server closest to the user responds to the request. If the requested content is already cached (stored) on that edge server, it can be delivered to the user without needing to fetch it from the original server.

Dynamic Content Optimization: CDNs can cache static content (like images and stylesheets) and dynamically generate content (like personalized pages) on the edge servers. This reduces the load on the origin server and speeds up content delivery.

Load Balancing: CDNs use load balancing algorithms to direct user requests to the nearest and least congested edge server. This distributes the traffic and ensures optimal performance, especially during high traffic periods.

Reduction of Latency: By delivering content from a server that is physically closer to the user, CDNs reduce latency (delay) in loading web pages. This is particularly beneficial for users accessing websites from different parts of the world.

Distributed Denial of Service (DDoS) Protection: Some CDNs offer DDoS protection by absorbing and mitigating malicious traffic directed at the origin server. The distributed nature of a CDN makes it more resilient to such attacks.

Scalability: CDNs can handle sudden spikes in traffic effectively, as they distribute the load across multiple servers. This is particularly useful during events like product launches or viral content sharing.

Content Compression and Optimization: CDNs can also perform content optimization tasks such as image compression, minification of scripts, and bundling resources to improve page load times.

In summary, a Content Delivery Network enhances the performance and availability of websites and web applications by caching content on distributed edge servers, optimizing delivery, reducing latency, and balancing traffic. It's an essential tool for providing a seamless and fast user experience, particularly for websites with a global audience.

2.3 Connect the Domain to Ghost and CDN

In this step, the Cloudfare is suggested to use as the CDN service provider because of its reliable and affordable service. Go to Cloudflare.com and register an account if you do not have one.

Then on the top right, enter the account home and add a site, and type in the domain that you bought in the last step.

Add a Site

Choose the free plan:

Free Plan

Then Cloudfare suggests that you replace the name server on your domain provider with theirs as highlighted in orange below.

Finish the Name Server Setup

So in the next step, go back to Namecheap and click manage for the domain that you bought:

Manage the Domain

Then, remove all other name servers and add the name servers of Cloudfare:

Add Name Servers of Cloudfare

It will take a few hours for Cloudfare to detect the change of name servers. So in the meanwhile, let's go the DNS section of your website on Cloudfare, and add 2 A records:

  • Your domain (e.g. vincentyuan.us) and AWS elastic IPv4 address
  • WWW + your domain (e.g. www.vincentyuan.us) and AWS elastic IPv4 address
Add A Record

So the results of those 2 A records look like these (the IP address have been masked):

DNS Setup

3 Conclusion

After setting it up, it takes a few hours to 1 day to take effects. After that, you are able to access the Ghost website through both the AWS elastic IP address and the domain.

Next, some tips to enhance the blog from both function and user interface perspectives will be shared!