postgrails   >   20200720-gitlab-pages-dns-namecheap  

GitLab Pages DNS at NameCheap

published 2020-07-20

GitLab pages is a great free website hosting service:

  • You can set up GitLab CI to automatically build and deploy your site when you commit.
  • You can bring-your-own domain name (I buy mine at NameCheap.com).
  • GitLab provides free SSL certs via LetsEncrypt.
  • GitLab.com itself is free to use for cheapskates, skinflints, and tightwads like me.

When you set up your GitLab pages website, GitLab wants you to verify that you own your domain. That's reasonable. However, it's necessary to translate GitLab's instructions into what is needed at NameCheap.

GitLab needs two DNS records:

  • A CNAME record that points from your domain to YourAccountName.gitlab.io. Here's GitLab's template for my site:

    seanharrison.org CNAME seanharrison.gitlab.io.
    
  • A TXT record with the domain verification code. Here's GitLab's template for my site:

    _gitlab-pages-verification-code.seanharrison.org TXT gitlab-pages-verification-code=********************************
    

When converting these to DNS records at NameCheap, the key thing is remember that in NameCheap DNS, the Host field should be the subdomain alone. So, in my case, I omit the root domain name (seanharrison.org) from the DNS record Host entries. Here's what it looks like on the "Advanced DNS" for seanharrison.org:

TypeHostValueTTL
CNAME Record@seanharrison.gitlab.io.1 min
TXT Record_gitlab-pages-verification-codegitlab-pages-verification-code=********************************1 min
  • In the CNAME record, Host = @, which means the root of the site.
  • In the TXT record, the Host = _gitlab-pages-verification-code.

Just remember that in NameCheap DNS, the Host is the subdomain alone. Once this is set up correctly, GitLab pages should be able verify your ownership of the domain and start the process of getting a LetsEncrypt SSL certificate in place. And you will be on your way to free static hosting with GitLab pages.