How to find source of 301/302 redirect loop? Heroku GoDaddy Zerigo

user179288 asked:

this should be a relatively simple problem but I’m having trouble.I hope this is the right forum to post on as I’ve seen people get booted off stack-overflow for this sort of thing. I’ve setup a web app on heroku (cedar stack) at my-web-app.herokuapp.com and I’m trying to direct my-domain.com and www.my-domain.com to it.

As per instructions on the heroku documentation, I’ve set my-domain.com to redirect (forwarding) to www.my-domain.com and then set a C-Name from www.my-domain.com to my-web-app.herokuapp.com. But the C-Name doesn’t seem to be working right and is sending back to my-domain.com, causing a loop and I can’t work out why.

I first configured these setting at GoDaddy.com where I registered the domain but then tried to avoid the problem by using Heroku’s Zerigo DNS add-on, setting the nameservers on GoDaddy to the ones given for Zerigo. However the problem remains.

Here is the output from dig for my-domain.com (“drop-circles.com”):

; <<>> DiG 9.3.2 <<>> any drop-circles.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 671
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 5

;; QUESTION SECTION:
;drop-circles.com.              IN      ANY

;; ANSWER SECTION:
drop-circles.com.       433     IN      NS      b.ns.zerigo.net.
drop-circles.com.       433     IN      NS      d.ns.zerigo.net.
drop-circles.com.       433     IN      NS      e.ns.zerigo.net.
drop-circles.com.       433     IN      NS      a.ns.zerigo.net.
drop-circles.com.       433     IN      NS      c.ns.zerigo.net.
drop-circles.com.       433     IN      SOA     a.ns.zerigo.net. hostmaster.zerigo.com. 1372250760 10800 3600 604800 900
drop-circles.com.       433     IN      A       64.27.57.29
drop-circles.com.       433     IN      A       64.27.57.24

;; ADDITIONAL SECTION:
d.ns.zerigo.net.        68935   IN      A       174.36.24.250
e.ns.zerigo.net.        69015   IN      A       72.26.219.150
a.ns.zerigo.net.        72602   IN      A       64.27.57.11
c.ns.zerigo.net.        69204   IN      A       109.74.192.232
b.ns.zerigo.net.        70549   IN      A       174.37.229.229

;; Query time: 15 msec
;; SERVER: 194.168.4.100#53(194.168.4.100)
;; WHEN: Wed Jun 26 14:29:07 2013
;; MSG SIZE  rcvd: 293

Here is the output from dig for www.my-domain.com (“www.drop-circles.com”):

; <<>> DiG 9.3.2 <<>> any www.drop-circles.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1608
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.drop-circles.com.          IN      ANY

;; ANSWER SECTION:
www.drop-circles.com.   407     IN      CNAME   drop-circles-website.herokuapp.com.

;; Query time: 19 msec
;; SERVER: 194.168.4.100#53(194.168.4.100)
;; WHEN: Wed Jun 26 14:29:15 2013
;; MSG SIZE  rcvd: 83

And from Fiddler if I use the inspector when I try either address I get a series of requests, with the my-domain.com (“drop-circles.com”) looking like this:

Request:

GET http://drop-circles.com/ HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-gb
User-Agent: Opera/9.80 (Windows NT 5.1; U; Edition IBIS; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: drop-circles.com

Response:

HTTP/1.1 302 Found
Server: nginx/0.8.54
Date: Wed, 26 Jun 2013 13:26:55 GMT
Content-Type: text/html;charset=utf-8
Connection: keep-alive
Status: 302 Found
Location: http://www.drop-circles.com/
Content-Length: 113

<html><body>Redirecting to <a href="http://www.drop-circles.com/">http://www.drop-circles.com/</a></body></html>

And the www.my-domain.com (“www.drop-circles.com”) looking like this:

Request:

GET http://www.drop-circles.com/ HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-gb
User-Agent: Opera/9.80 (Windows NT 5.1; U; Edition IBIS; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: www.drop-circles.com

Response:

HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Date: Wed, 26 Jun 2013 13:26:56 GMT
Location: http://drop-circles.com/
Vary: Accept
X-Powered-By: Express
Content-Length: 104
Connection: keep-alive

<p>Moved Permanently. Redirecting to <a href="http://drop-circles.com/">http://drop-circles.com/</a></p>

Any and all help would be greatly appreciated. If it is not at all obvious from these readouts what it might be could someone at least tell me which company GoDaddy, Zerigo or Heroku should I go to for support since I don’t really know enough to be able to say where the problem lies. Thank you.


I answered:

Your Node application is sending the redirect from www.drop-circles.com to drop-circles.com. Remove whatever is causing it to send that redirect and you will find that your app starts working.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.