DNS when hosting a static website on Google Cloud Platform bucket

百般思念 提交于 2021-02-05 07:13:06

问题


Sorry if my question may seem messy I have only a basic idea about DNS or hosting. The story is the following:

I have created a couple of my personal webpages and registered a domain. Then I found out that I don't need a "big" hosting for my couple of pages and it's better to host a website in the cloud, I chose GCP for hosting, found this tutorial and followed through to successfully achieve my goal of hosting a static website.

Then I wanted to share a link to my website in social media and found out that Open Graph Protocol meta information I've added to my website is not displaying while the site is working ok. Strange thing, I thought and started searching. I found Facebook debugger tool and used it to check my website only to see the "Could not resolve the hostname into a valid IP address." response.

I searched for more information about that issue and found a StackOverflow question, where it's said something about domain, hosting, and DNS. Basically, I figured out that DNS servers in my domain registrar's panel are configured for the registrar's hosting while I use GCP for hosting. And I need those DNS servers to match for OGP meta info to work properly.

Any research that I dis, lead me to GCP DNS. But I'm not sure that configuring GCP DNS (which is not GCP bucket storage that I use for hosting my static website) is a good idea or the right way to solve my issue.

Do I need to configure GCP DNS, create VM, and host my website there? Or do I need to specify some special GCP DNS servers in my domain registrar's control panel? Or do I need to do something else?

Please, point me in the right direction. I need my website not just to be available on the internet as a hyperlink, I want the OGP metadata to be available and visible when sharing the link in social media. I don't mind if my website will be hosted on a bucket or on VM of GCP DNS, I just want to understand in what direction I should dig.

Details: My domain is http://www.vladimir-markiev.name/. I followed every step of GCP tutorial exactly as described in documentation: enabled billing, verified domain ownership, configured CNAME record at domain registrar's DNS to www. vladimir-markiev.name (that www. in the beginning irritates me a little, maybe I'll try to deal with it later). I managed access to my bucket to "public and can be accessed by anyone on the internet". I can add my own list of DNS servers to my domain - the registrar allows to do that.

Update: Somehow CNAME record was missing from my domain. I configured it to point to GCP. Check successful.

I also ran a DNS check and it gave out some issues:

CNAME www → c.storage.googleapis.com.

But the issue persists.

Ask me any additional questions for clarification, I tried to include as much information as possible but could have missed something


回答1:


When I checked DNS records for your domain first time I found that you misconfigured CNAME record:

$ dig CNAME www.vladimir-markiev.name

; <<>> DiG 9.11.5-P4-5.1-Debian <<>> CNAME www.vladimir-markiev.name
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 60848
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.vladimir-markiev.name.     IN      CNAME

;; AUTHORITY SECTION:
vladimir-markiev.name.  600     IN      SOA     ns1.reg.ru. hostmaster.ns1.reg.ru. 1588872137 14400 3600 604800 10800

;; Query time: 105 msec
;; SERVER: 100.115.92.193#53(100.115.92.193)
;; WHEN: Fri May 08 14:44:35 CEST 2020
;; MSG SIZE  rcvd: 111

To solve your issue you should go back to the domain registrar side and fix DNS zone configuration.

As I can see at the screenshot of MXToolbox you did all the necessary changes and site is accessible for me. Have a look at some checks below:

CNAME record is configured properly:

$ dig CNAME www.vladimir-markiev.name

; <<>> DiG 9.11.5-P4-5.1-Debian <<>> CNAME www.vladimir-markiev.name
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12444
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.vladimir-markiev.name.     IN      CNAME

;; ANSWER SECTION:
www.vladimir-markiev.name. 85906 IN     CNAME   c.storage.googleapis.com.

;; Query time: 18 msec
;; SERVER: 100.115.92.193#53(100.115.92.193)
;; WHEN: Fri May 08 15:42:51 CEST 2020
;; MSG SIZE  rcvd: 92

$ host www.vladimir-markiev.name
www.vladimir-markiev.name is an alias for c.storage.googleapis.com.
c.storage.googleapis.com has address 216.58.215.80
c.storage.googleapis.com has IPv6 address 2a00:1450:401b:806::2010

and you site is reachable via browser and curl:

$ curl -I  www.vladimir-markiev.name 
HTTP/1.1 200 OK
X-GUploader-UploadID: AAANsUnbpBaaL4YoepXEs5QRGjeVIkR94Eywdtot02oL3xOPcPRYP6KyPUmf5q_b140hLBhutYQsYbuCglL8nvU2oQ
Expires: Fri, 08 May 2020 14:34:23 GMT
Date: Fri, 08 May 2020 13:34:23 GMT
Last-Modified: Fri, 08 May 2020 12:14:02 GMT
ETag: "53d6f21bb90302f77b655904dd5f4e4d"
x-goog-generation: 1588940042495901
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 19830
Content-Type: text/html
x-goog-hash: crc32c=ziXBHQ==
x-goog-hash: md5=U9byG7kDAvd7ZVkE3V9OTQ==
x-goog-storage-class: STANDARD
Accept-Ranges: bytes
Content-Length: 19830
Server: UploadServer
Cache-Control: public, max-age=3600
Age: 958 

$ curl  www.vladimir-markiev.name | head 
...
<!DOCTYPE html>
<html lang="ru">

<head prefix="og: http://ogp.me/ns#">
    <meta charset="utf-8">
    <meta http-equiv="content-type" content="text/html">
    <title>Главная страница - Владимир Маркиев</title>
    <link rel="stylesheet" href="style.css">
    <meta name="robots" content="follow, index" />
    <meta name="description" content="Владимир Маркиев, Vladimir Markiev: Технический писатель в Санкт-Петербурге сайт-визитка." />
 67 19830   67 13395    0     0  12.7M      0 --:--:-- --:--:-- --:--:-- 12.7M
curl: (23) Failed writing body (429 != 5632)

If you still not able to open your website in browser you should wait for a while because of DNS propagation time ( changes usually take 24 to 48 hours).



来源:https://stackoverflow.com/questions/61676499/dns-when-hosting-a-static-website-on-google-cloud-platform-bucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!