Using PointDNS on Heroku to manage SSL and non-www to www redirects

爷,独闯天下 提交于 2019-12-30 05:07:26

问题


I've been using Heroku to host and manage a website of mine that requires an SSL certificate. For the last year and a half I've been using ZerigoDNS to manage my domain and SSL redirecting (although, redirecting from non-https, non-www to https and www does not work).

I just got a notice from Heroku that they will be shutting down ZerigoDNS soon and they recommend switching to PointDNS. I couldn't find any information in the PointDNS documentation about managing SSL redirects.

Here's what I'm looking to do:

  1. non-www non-https redirects to https and www

  2. non-https redirects to https and www

  3. https but non-www redirects to https and www

The reason everything needs to be forwarded to https and www is that's what the ssl cert was created for (the www is required. I don't have a wildcard certificate).

Does anyone familiar with PointDNS know how to to set up the records and redirects properly?

Thanks in advance!


回答1:


First, dd both www.your-domain.com and your-domain.com as custom domains under settings or run below commands

heroku domains:add domainname.com
heroku domains:add www.domainname.com

For redirection, you need to do it via server, eg. if you are using apache you can achieve redirections via .htacess file.

Also there is no relevant information available for PointDNS regarding forwarding.




回答2:


Regarding non-www to www redirects, I just got that to work as follows:

First, you must add both www.your-domain.com and your-domain.com as custom domains.

heroku domains:add andrewpuglionesi.com
heroku domains:add www.andrewpuglionesi.com

I have a CNAME record with name www.my-domain.com.. The text in its data field is my-heroku-domain.herokuapp.com. I also have an alias record with the name my-domain.com., and I made its data field www.my-domain.com. In other words, the alias just points to the CNAME.

I don't know if this is well-advised, but it seems to work (and without sticking www in the user's URL, at that). It simply solves the problem where you can't access pages other than the index without having www there). I like how Heroku and PointDNS' documentation both say you can easily do redirects and then don't actually explain how to... I guess this is one way.

I've previously been able to force https protocol through the backend of a Django site. I can't remember the exact method I used, but you might be able to do it without the DNS stuff.



来源:https://stackoverflow.com/questions/41989136/using-pointdns-on-heroku-to-manage-ssl-and-non-www-to-www-redirects

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