How to configure Google Domains + Heroku w a Naked Domain

我的未来我决定 提交于 2019-11-26 07:46:04

问题


I have a domain loading in a web browser using Heroku and Google Domains. Right now the domain loads with a www: http://www. XXX .com.

If I enter the URL w/o the WWW like http:// XXX .com I get the following error in Chrome: \"XXX.com’s server DNS address could not be found\"

What do I need to do so that the following happens:

  1. This loads - http:// mydomain.com
  2. http://www. mydomain.com redirects to http:// mydomain.com

Thank you


回答1:


IMHO, you should:

1/ Set your heroku domain to be http://example.com. All the info are in the Heroku documentation.

Heroku should serve your site using http://example.com.

2/ You need to redirect in Google Domains your http://www.example.com to http://example.com. To do this, you need to set web forwarding in the Google Domain console under the website tab. The documentation is straight forward.

Any http://www.example.com request should be forwarded to http://example.com.

UPDATE

Due to your needs, I am wondering if the best is not to disable the naked to www redirection, have both domain points to your heroku instance and get a SSL certificate for them (using let's encrypt makes things easy).

Here is a tutorial.

I hope this helps!




回答2:


It's advisable to make the www subdomain the default here, such that the root/naked domain redirects to www. This is in line with Heroku recommendations, which states:

For maximum scalability and resiliency applications should avoid using DNS A-records and instead use a DNS provider that supports CNAME functionality at the apex, or use sub-domains exclusively

You can achieve this with Google Domains Synthetic Records:

  • Go to the Synthetic Records section
  • Select Subdomain forward
  • Enter @ for subdomain, and www.xyz.com for destination


来源:https://stackoverflow.com/questions/41390282/how-to-configure-google-domains-heroku-w-a-naked-domain

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