问题
I created a site with Hugo and I hosted it as a gitlab page.
To assign my custom domain I followed the instructions of this document of gitlab.
I created three DNS records:
- one of type
Awith name@and value35.185.44.232; - one of type
TXTwith name@and value_gitlab-pages-verification ...for the verification of the ownership of the domain; - one of type
Awith namewwwand value35.185.44.232.
If I access the site using the address https://example.com everything works normally; but if I log in using the triple W (www.example.com) I get from gitlab the error message 401 You don't have permission to access the resource. The resource that you are attempting to access is protected and you don't have the necessary permissions to view it.
How can I correct it?
回答1:
Try a CNAME instead of a second A record for your WWW. subdomain. Having two A records - one that points to your naked domain and one that points to your WWW-domain is either causing redirect error or simply does not exist since it, as your origin's subdomain, must exist as a separate entity on GitLab OR you can not concern yourself with it by using a CNAME record as I previously recommended and using a directory-style (as opposed to a subdomain-style) setup for your site. Each has its own benefits as well as drawbacks. I use the CNAME method and have a WWW-subdomain setup on GitLab in order for my sites to grant that extra bit of security and privacy to visitors that having a TLS cert installed on the WWW-subdomain offers.
来源:https://stackoverflow.com/questions/60515412/unreachable-gitlab-page-with-custom-domain