Why is my Github-hosted site responding with HTTP 302 instead of 200?

前端 未结 3 1840
无人及你
无人及你 2021-02-01 08:14

I own the domain penkov.id.au. I host a blog using github, with an A record for the subdomain michael.penkov.id.au pointing to the github pages server (204.232.175.

相关标签:
3条回答
  • 2021-02-01 08:36

    I'm met with a 200 HTTP response.:

    GET http://michael.penkov.id.au/blog/2014/01/02/reinventing-the-wheel.html
    
    HTTP/1.1 200 OK
    Server: GitHub.com
    Date: Thu, 02 Jan 2014 16:04:17 GMT
    Content-Type: text/html
    Connection: keep-alive
    Content-Length: 10314
    Last-Modified: Thu, 02 Jan 2014 14:38:15 GMT
    Expires: Thu, 02 Jan 2014 16:14:17 GMT
    Cache-Control: max-age=600
    Vary: Accept-Encoding
    Accept-Ranges: bytes
    Vary: Accept-Encoding
    

    You're likely waiting for Facebook (and other services') DNS cache to flush. It shouldn't take more than 48 hours. I can sometimes get the Facebook Debugger to return a 200, but it still has errors, because of this HTML tag on the page pointing elsewhere:

     <link rel="canonical" href="http://penkov.id.au/blog/2014/01/02/reinventing-the-wheel.html" />
    

    enter image description here

    0 讨论(0)
  • Here's what I heard from github support:

    The A record pointing to 204.232.175.78 is what's causing the 302 redirect.

    Replacing the A record with a CNAME (pointing to mpenkov.github.com) in my DNS settings fixed the problem.

    For reference, here's what my DNS record looks like now:

    misha@misha-antec:~$ dig michael.penkov.id.au +nocomments +nocmd +nostats
    
    ; <<>> DiG 9.8.1-P1 <<>> michael.penkov.id.au +nocomments +nocmd +nostats
    ;; global options: +cmd
    ;michael.penkov.id.au.          IN      A
    michael.penkov.id.au.   85536   IN      CNAME   mpenkov.github.com.
    mpenkov.github.com.     2736    IN      CNAME   github.map.fastly.net.
    github.map.fastly.net.  25      IN      A       103.245.222.133
    
    0 讨论(0)
  • 2021-02-01 08:46

    Coincidentally, I ran into a similar issue because I'm using CloudFlare to manage my DNS and GitHub pages on an apex domain. I have two A records pointing to the GitHub Pages servers 192.30.252.153 192.30.252.154 and a CNAME on www subdomain pointing to the root domain.

    I asked GitHub support about the random 302 redirects I've been seeing and they told me this:

    Because you are using Cloudflare with A records you are running into our Denial of Service (DOS) mitigation technology.

    In order to avoid this issue, you could use a sub domain, e.g. blog.example.com, instead of an apex domain, e.g. example.com, as a CNAME for your GitHub Page. This sub domain will be backed by our Content Delivery Network and won't return a 302.

    If you would like to use apex domains you will need to point them directly at the GitHub Pages IPs.

    Luckily (or not), CloudFlare does offer the chance of breaking the RFC compliance and allow the use of CNAME records on naked domains. Of course it could break the email service, but I'm fine with that because I'm not making use of it.

    Hope this helps someone.

    0 讨论(0)
提交回复
热议问题