为什么我的Github托管网站使用HTTP 302而不是200? [英] Why is my Github-hosted site responding with HTTP 302 instead of 200?

查看:232
本文介绍了为什么我的Github托管网站使用HTTP 302而不是200?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有 penkov.id.au 域名。我使用博客 //help.github.com/articles/setting-up-a-custom-domain-with-pages\"> github ,其子域名为 michael.penkov.id的A记录。 au 指向github页面服务器(204.232.175.78)。

  bash-3.2 $ dig michael.penkov.id.au + nocomments + nocmd + nostats 

; <<>> DiG 9.8.3-P1> michael.penkov.id.au + nocomments + nocmd + nostats
;;全局选项:+ cmd
; michael.penkov.id.au。在A
michael.penkov.id.au。 86400 IN A 204.232.175.78
penkov.id.au。 14399 IN NS ns1.linode.com。
penkov.id.au。 14399 IN NS ns5.linode.com。
penkov.id.au。 14399 IN NS ns4.linode.com。
penkov.id.au。 14399 IN NS ns2.linode.com。
penkov.id.au。 14399 IN NS ns3.linode.com。
ns1.linode.com。 62648 IN A 69.93.127.10
ns1.linode.com。 136520 IN AAAA 2600:3c00 :: a
ns2.linode.com。 67499 IN A 65.19.178.10
ns2.linode.com。 122812 IN AAAA 2600:3c01 :: a
ns3.linode.com。 124971 IN A 75.127.96.10
ns3.linode.com。 133162 IN AAAA 2600:3c02 :: a
ns4.linode.com。 96383 IN A 207.192.70.10
ns4.linode.com。 904 IN AAAA 2600:3c03 :: a
ns5.linode.com 44638 IN A 109.74.194.10
ns5.linode.com。 56329 IN AAAA 2a01:7e00 :: a

最近(大约一个月前,也许更多),我发现对子域的所有请求(例如 http:// michael .penkov.id.au / blog / 2014/01/02 / reinventing-the-wheel.html )得到了302回应。这是一个像facebook.com这样的网站的问题,它不会打扰访问该网址以提供预览。 Github 注意事项 302重定向不是错误,应该遵守,但Facebook显然是忽略了这一点。



我看过请求&使用Chrome调试工具的回复标头:



请求:

  GET / blog / 2014/01/02 / reinventing-the-wheel.html HTTP / 1.1 
主机:michael.penkov.id.au
连接:keep-alive
缓存控制:max- age = 0
接受:text / html,application / xhtml + xml,application / xml; q = 0.9,image / webp,* / *; q = 0.8
用户代理:Mozilla / 5.0 X11; Linux x86_64)AppleWebKit / 537.36(KHTML,像Gecko)Chrome / 31.0.1650.63 Safari / 537.36
接受编码:gzip,deflate,sdch
接受语言:en-US,en; q = 0.8,ja; q = 0.6,ru; q = 0.4
Cookie:__utma = 146715829.533338776.1383309288.1383487335.1383547294.7; __utmz = 146715829.1383309288.1.1.utmcsr =(直接)| utmccn =(直接)| utmcmd =(无); __utma = 118121621.1819750941.1383609188.1387026971.1388676605.15; __utmb = 118121621.11.10.1388676605; __utmc = 118121621; __utmz = 118121621.1387026971.14.7.utmcsr = facebook.com | utmccn =(referral)| utmcmd = referral | utmcct = /
If-Modified-Since:Thu,02 Jan 2014 14:38:15 GMT

回应:

  HTTP / 1.1 302找到
连接:关闭
Pragma:no-cache
cache-control:no-cache
位置:/ blog / 2014/01/02 / reinventing- the-wheel.html

最后,一个确定的方式来重现这个问题是使用 Facebook网址调试工具。请点击 http://michael.penkov.id.au/blog /2014/01/02/reinventing-the-wheel.html 查看问题。



我的问题:




  • 导致重定向的是什么?是A记录吗?

  • 重定向到哪里?我怎么能找到这个?如何修复?

  • 我可以摆脱重定向吗?换句话说,如何让服务器返回200而不是302?具有相同设置的其他网站(例如 http://mdswanson.com/blog/ 2013/11/13 / some-tools-i-like.html )回覆200。


解决方案

这是我从github支持中听到的:


指向204.232.175.78的A记录是什么导致302重定向。


使用CNAME(指向mpenkov.github.com)在我的DNS设置中替换A记录修复了问题。 / p>

为了参考,以下是我现在的DNS记录:

  misha @ misha-antec:〜$ dig michael.penkov.id.au + nocomments + nocmd + nostats 

; <<>> DiG 9.8.1-P1<> michael.penkov.id.au + nocomments + nocmd + nostats
;;全局选项:+ cmd
; michael.penkov.id.au。在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


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.78).

bash-3.2$ dig michael.penkov.id.au +nocomments +nocmd +nostats

; <<>> DiG 9.8.3-P1 <<>> michael.penkov.id.au +nocomments +nocmd +nostats
;; global options: +cmd
;michael.penkov.id.au.          IN      A
michael.penkov.id.au.   86400   IN      A       204.232.175.78
penkov.id.au.           14399   IN      NS      ns1.linode.com.
penkov.id.au.           14399   IN      NS      ns5.linode.com.
penkov.id.au.           14399   IN      NS      ns4.linode.com.
penkov.id.au.           14399   IN      NS      ns2.linode.com.
penkov.id.au.           14399   IN      NS      ns3.linode.com.
ns1.linode.com.         62648   IN      A       69.93.127.10
ns1.linode.com.         136520  IN      AAAA    2600:3c00::a
ns2.linode.com.         67499   IN      A       65.19.178.10
ns2.linode.com.         122812  IN      AAAA    2600:3c01::a
ns3.linode.com.         124971  IN      A       75.127.96.10
ns3.linode.com.         133162  IN      AAAA    2600:3c02::a
ns4.linode.com.         96383   IN      A       207.192.70.10
ns4.linode.com.         904     IN      AAAA    2600:3c03::a
ns5.linode.com.         44638   IN      A       109.74.194.10
ns5.linode.com.         56329   IN      AAAA    2a01:7e00::a

Recently (around a month ago, maybe more), I've found that all requests to the subdomain (e.g. http://michael.penkov.id.au/blog/2014/01/02/reinventing-the-wheel.html) are met with a 302 response. This is a problem for sites like facebook.com, which don't bother accessing that URL to provide previews. Github notes that 302 redirects are not errors and should be followed, but Facebook apparently ignores that.

I had a look at the request & response headers using Chrome's debugging tools:

Request:

GET /blog/2014/01/02/reinventing-the-wheel.html HTTP/1.1
Host: michael.penkov.id.au
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,ja;q=0.6,ru;q=0.4
Cookie: __utma=146715829.533338776.1383309288.1383487335.1383547294.7; __utmz=146715829.1383309288.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=118121621.1819750941.1383609188.1387026971.1388676605.15; __utmb=118121621.11.10.1388676605; __utmc=118121621; __utmz=118121621.1387026971.14.7.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/
If-Modified-Since: Thu, 02 Jan 2014 14:38:15 GMT

Response:

HTTP/1.1 302 Found
Connection: close
Pragma: no-cache
cache-control: no-cache
Location: /blog/2014/01/02/reinventing-the-wheel.html

Finally, a sure way to reproduce this problem is to use the Facebook URL debugging tool. Point it at http://michael.penkov.id.au/blog/2014/01/02/reinventing-the-wheel.html to see the problem.

My questions:

  • What is causing the redirect? Is it the A-record?
  • Where is the redirect actually to? How can I find this out? How can I fix it?
  • Can I get rid of the redirect? In other words, how do I get the server to return 200 instead of 302? Other sites with an identical setup (e.g http://mdswanson.com/blog/2013/11/13/some-tools-i-like.html) respond with 200.

解决方案

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

这篇关于为什么我的Github托管网站使用HTTP 302而不是200?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆