How to Use Fastly to Point a Subdomain to Another Website

Last update: 08-08-2024

Have you ever needed to point a subdomain to another website without access to its IP address? This guide will walk you through the process of using Fastly, a content delivery network (CDN), to accomplish this task. We'll be using Hostinger for domain management, but the principles apply to other domain registrars as well.

Why Use Fastly?

Fastly allows you to use CNAME records instead of A records, which is particularly useful when you don't have access to the target website's IP address. This method is perfect for scenarios like pointing your domain to a Node.js application hosted on platforms like Glitch.com.

Step-by-Step Guide

1. Set Up Fastly Service

  1. Log in to your Fastly account.
  2. Click "Create service" in the top right corner, then select "CDN".
  3. Provide a service name (for identification purposes) and your domain. Using a subdomain like www.your-domain.com is recommended for easier configuration.
  4. Add an "origin" - the actual website you're pointing to. For example, if it's a Glitch website, it might look like placid-ruby-firewall.glitch.me. Remember to remove the https:// prefix and any trailing slashes.
  5. Leave the recommended settings as they are (all three toggle buttons on), then click "Activate".

2. Configure TLS

  1. From the side menu, navigate to "Security" > "TLS Management" > "Subscriptions".
  2. Click "Secure another domain" in the top right corner.
  3. Enter your subdomain (e.g., www.your-domain.com) and click "Add".
  4. Choose a certification authority. Fastly offers two options:
    • Certainly: This is Fastly's own certification authority (Fastly seems to promote this option harder).
    • Let's Encrypt: This is a widely used, free, and automated certificate authority.

    In my case, choosing Certainly led to errors and complications (maybe due to existing CAA records associated with Hostinger's certificates? I'm not sure), but I found that switching to Let's Encrypt was a more straightforward solution. It seemed to bypass any potential conflicts and was overall easier to work with - so I opted for the Let's Encrypt option.

  5. For TLS configuration, use the default: HTTPS/3 & TLS v1.3 + ORTT(t.sni).
  6. Click the submit button.

3. Verify Your Domain

  1. Log into your Hostinger account (or wherever you manage your domains) and select "Domains" from the top menu.
  2. Choose the domain you want to use.
  3. Click "DNS/Nameservers" from the left menu.
  4. Review your DNS records. If a CNAME record with the name 'www' exists, delete it.
  5. Create two new DNS CNAME records:
    1. First record:
      • Type: CNAME
      • Name: Copy from Fastly's "ACME DNS challenge" (usually _acme-challenge followed by your subdomain, e.g., _acme-challenge.www)
      • Target: Value provided by Fastly (e.g., pqvbfvn07y3pmj51pv.fastly-validations.com)
      • TTL: 300
    2. Second record:
      • Type: CNAME
      • Name: Your subdomain (e.g., www)
      • Target: t.sni.global.fastly.net
      • TTL: 300

4. Wait for Verification and Activation

  1. After creating the CNAME records, wait a few minutes.
  2. You should see a message: "We are waiting for the response from the certificate authority. Sit back and relax."
  3. Wait for the certificate to be issued. You'll see a message saying "Activated - Certificate issued."
  4. Allow a few more minutes for the updates to propagate through Fastly's servers.

Conclusion

After following these steps, you should be able to access your target website using the subdomain you configured. This method provides a flexible way to point your domain to various web applications without needing direct access to their IP addresses.

Remember that DNS propagation can take some time, so if it doesn't work immediately, give it a little more time before troubleshooting.

0 Comments

Add a new comment: