Production redirect loop error on root domain, but not with www - heroku

I'd like when a user types the domain YOURSITE.com to not go into a loop and crash. I've searched for answers for a couple days now and can't seem to find the exact one.
Error from chrome: This webpage has a redirect loop - The webpage at http://YOURSITE.com/ >has resulted in too many redirects. Clearing your cookies for this site or allowing third->party cookies may fix the problem. If not, it is possibly a server configuration issue and >not a problem with your computer.
Background:
Rails 3.2.14 App with Ruby 2.0.0
Domain bought with godaddy
Hosting on Heroku with both domains setup www.YOURSITE.com and YOURSITE.com
Using AWS with route 53 and S3.
Let me know what relevant code you need to help or if this is something that is being caused by AWS or the like. I've tried an reversed several different things via my code, but can't seem to find anything that works.

you should log into your Heroku dashboard, click on the app and then click on the "Production Check" button. This will help you check for DNS issues among other.
Check your DNS Zone file with godaddy. How are you redirecting the sub domain www to the host domain?
On your rails app, how is your route.rb file handling the incoming traffic? do you have any redirection there?
Hope that helps..

There is a very good write up that goes through configuration settings between AWS, the domain registrar (in my case godaddy), and heroku here: https://devcenter.heroku.com/articles/route-53#naked-root-domain I used this originally when I set up my site.
I wish I could say I know what the problem was, but I'm not totally sure what it was. My guess is that it had to do with APEX domains being unsupported by AWS and/or Heroku, and therefore I needed not to try to redirect. Here's the settings that worked for me:
Godaddy domain mysite.com, transferred my DNS stuff to AWS (I had done that prior to the problem)
Heroku: you can either use the CL or you can access the settings for your app online. In either situation I set up my domains to be mysite.com and www.mysite.com
AWS: This is a little trickier. You need to make sure the settings for Route 53 and S3 are exactly like in the tutorial link above. Your mysite.com bucket in S3 must redirect to www.mysite.com.
This isn't ideal and there are probably ways to get around this using different companies for hosting/DNS services, but with the Heroku/AWS combo this is what I had to do to stop the redirect loop.

Related

Unable to set up custom domain on Heroku using Google Domains DNS?

To preface this, I am new to backend web development so I'm coming at this totally clueless. My past experience is with Netlify, which makes it pretty seamless to add a custom domain to a website with their free DNS service.
To start, I am working on a Flask application that ideally I would like to put on a subdomain of my website (i.e. app.my-website.whatever, not actually my real domain since it includes my real name) on a different host, in this case Heroku, while keeping my main website (www.my-website.whatever) on Netlify. This required me to switch from using Netlify's DNS to using the DNS tools provided by Google Domains.
After deploying the app on the free domain, which went just fine, I tried setting up my domain for the website, following these steps:
On my website's dashboard, I went to Settings > Domains > Add domain and under domain entered app.my-website.whatever, including the subdomain of course.
Copied the DNS Target Heroku gave me.
At my dashboard for my-website.whatever at domains.google.com, under DNS > Default name servers > Resource records, I added a custom record with the hostname app.my-website.whatever (Google Domains automatically adds the .my-website.whatever), type CNAME, TTL 600, and in the Data field I pasted the DNS Target.
In my Ubuntu (WSL) terminal, when I type host app.my-website.whatever, the output says app.my-website.whatever is an alias for {bunch-of-random-characters}.herokudns.com.
Unfortunately, this has not been successful. When I try to visit the domain, I usually get an error such as DNS_PROBE_FINISHED_NXDOMAIN or alternatively ERR_SSL_UNRECOGNIZED_NAME_ALERT. I've also tried the same thing with just www.my-website.whatever, and the same issues occur.
When I try to visit the site, most browsers will automatically append https://, which I would assume doesn't quite work since I do not have a cert set-up for my site, which I need to do manually.
Does the above error mean that there is a problem related to SSL, or is it something else? Is it because my browser forces https:// that I cannot see anything changing (i.e. would http:// work?)?
From what I can tell, I should be able to do all of this on the free-tire, but I have some confusion about a few details, and feel like I could be missing some other things:
Do I need a certificate/SSL for my custom domain to work at all with Heroku?
If it could possibly be an easier solution: Is there a better alternative to Heroku in my case?
With regards to setting up the cert, I tried following the tutorial here:
https://medium.com/#bantic/free-tls-with-letsencrypt-and-heroku-in-5-minutes-807361cca5d3
For certbot, as the tutorial explains, you are given two strings like so: <long-string>.<other-long-string>, and you need to serve a file at /.well-known/acme-challenge/ with the name <long-string> (no extension), but as an unrelated issue, I cannot get Flask to serve this file, even on a local dev server, and I just get a 404 message, which the certbot utility also reports. I can create another file, such as a simple .txt file, in that same directory, and it will serve just fine.
I'll admit, these issues feel a bit basic, but I genuinely am lost, and none of the guides or posts I see online seem to have any remedy or explanation for what is happening here.
If there is any more information I should share, please let me know.

Heroku application not accessible on Safari

So I have a rails multi-tenant project running on Heroku where we identify what to serve based on the domain you access from. These domains are added to the app's heroku domains and the cname records provided by Heroku for www.domain.com are added to the domain's DNS and we also add a permanant redirect rule for domain.com/* -> www.domain.com/$1 so that people can access without a www.
This all works perfectly fine on Chrome/Firefox, but on Safari and IOS devices we've been getting reports and were able to reproduce that the websites simply timeout.
I have tried to monitor traffic with wireshark, I can see the GET HTTP request going out but nothing comes back.
I have tried to access the app directly using the appname.herokuapp.com URL, it works perfectly fine in that case.
I have tried accessing with a VPN (Cloudflare WARP), the issue is not present in this case. However I tried manually setting the DNS to Cloudflare's and that did not fix the issue. I have also tried 3 different ISPs and that was also not the issue.
So to sum up, the issue happens if:
You're accessing using a domain that POINTS TO a CNAME record (xxx.herokudns.com) that POINTS TO the app.
You're not using a VPN/Cloudflare WARP.
You're on Safari.
I have found a reference for this issue here but this dates back to 2015. I also have doubts that this Safari update could be relevant.
Has anyone been through this previously or can provide insights on to how I can further debug this?

How to find out where my website is hosted

I've looked at this answer and it doesn't solve my problem.
I just switched to a new site builder. Previously I was using Kajabi. Now i'm using GroovePages (GP). I switched DNS Settings in GoDaddy to GP's custom DNS servers, but now I am seeing 2 different websites when I go to the WWW version and the NON-WWW version of my website. The NON-WWW is correctly showing the page i built on GP, whereas the NON-WWW is not.
To make a long story short, I've been through long email threads with each company and seems like neither one knows how/why the WWW is not properly routing to the new site. GroovePages claims they have proper CNAME record set, as they are the ones managing the DNS records. Kajabi claims to have reset any lingering records also.
Currently the WWW version is pointing to Heroku, but I don't even have a Heroku account and haven't used them to host my website.
How do I fix this problem?
You need to make sure when you setup Forwarding that you forward to www.mysite.com instead of mysite.com
Link to forward my domain: https://in.godaddy.com/help/forward-my-domain-12123

How to setup laravel to use one app and point multiple domains to it

I have multiple domains, and would like to point them all to the same app. I want them all to serve the same pages, but the way it's setup now, I get a 404 not found if I try to go anywhere in the app other than the home page.
I have the nginx server block setup with server maindomain.com www.maindomain.com seconddomain.com www.seconddomain.com thirddomain.com www.thirddomain.com
I also have SSL certificates setup for all the domains listed, and the test out with an A from SSL labs. Question is, how do I get them all to serve the pages in the app, and not just the main domain's homepage?
I have looked at similar questions, but they don't seem to address this exact issue. I don't want multiple domains pointing to different views (that's cool, but not what I need), and I already have a different app with a different name hosted on the same server and working correctly. I've tried forwarding in the past, but it didn't work out (SSL issues).

Chrome on mac adding www before subdomain

I have recently hosted my site which intends to use wildcard subdomains in its general use. A user would go to account.website.com to access their part of the site. The site is a rails app hosted on heroku and domain is through 123-reg. DNS is set up as per heroku - * , cname , wildcard.app.heroku...
At first i thought 123-reg couldnt handle wildcard routing and i would have to change dns provider as whenever i go to account.website.com it will send me to www.account.website.com which is extremely irritating, but then i found that this does not happen on my windows machine, only on my dev machine (macbook pro). In both cases i am using Chrome. Firefox works as desired, only chrome is messing up.
Any insight into why this is happening would be fantastic.
Thanks
Obviously i immediately solve it after asking and look like a fool - Apparently the cache remembers the redirect from when i assume i hadnt yet set up dns correctly. If you get the same problem, clear browser cache

Resources