Trying to set up a subdomain using namecheap.com to point to your custom Gitlab Page was much more annoying that expected. Gitlab’s Documentation on the subject was quite a bit confusing when attempting to replicate it using Namecheap’s DNS management…
Namecheap is the domain registrar which provides my
gavs.space domain name.
What I wanted to do was point
http://gavinnl.gitlab.io. To do that you need to do three steps:
- Create a Gitlab page for yourself
- Configure your Gitlab Page with the new domain
- Set up the Namecheap DNS
Create a Gitlab Page
Creating a Gitlab Page is pretty easy. Simply create a repository under your
ACCOUNTNAME.gitlab.io. Now any code you push to that repo will
Configure your Gitlab Page with the new domain.
Once you have created your Gitlab page. Go to your project’s page and in the
New Domain and add your new subdomain. Note: in this image I have
blog2.gavs.space while the remaining images have
blog.gavs.space, this is
because I took this screenshot after I had already set everything up for
Just assume blog2 == blog.
I also disabled
Force HTTPS since I didn’t feel like buying an SSL certificate.
Once you have set up your subdomain, you should get a screen that looks like this:
Set up the Namecheap DNS
Now in your Namecheap Advanced DNS setup, add the following lines. Note your values will be different from what I have below. Your values should be pulled from the Gitlab Pages domain setup.
The IP address
188.8.131.52 is the main IP address of the Gitlab Pages
server. Everyone’s Gitlab page resides at the same IP addres. To distinguish
your page from someone else’s, you will need to add the TXT record that was
generated for you. If you do not add this you will get an error when trying to
access your domain.
Once you have the DNS information set up. You should be able to go back to your Gitlab Pages settings and click the
Retry Verification button. If everything was setup correctly, your page should be verified and look like this:
Now accessing your subdomain will point you to your hosted Gitlab page.
References and Credits
- This StackOverflow question
- This Gitlab Issue
- Header Image by: unsplash-logoPankaj Patel