用Nginx反向代理Feedburner

虽然博客将死,RSS将死的言论越来越盛,但如果真的要代理Feed,除了Feedburner可能没有更好的选择了,Feedsky什么的各种不靠谱。至于要反向代理Feedburner的原因我就不说了,老舍先生的茶馆里已经说的很清楚了。

实现的主要问题是:个人的Feedburner页面和页面中其他元素的目录结构不同。
如,我的Feedburner页面地址是http://feeds.feedburner.com/huxuan,
而其他如定义xml结构的xsl文件地址是http://feeds.feedburner.com/~d/styles/rss2full.xsl。
所以不能简单的反向代理个人页面,更不能直接反向代理feedburner根目录。
折腾纠结了两天,经过向 lqswkl 两位大牛请教,得到了两条不同的思路。

思路一:根目录反向代理http://feeds.feedburner.com,并将根目录重定向至/huxuan。
需要注意只重定向根目录,不重定向根目录下的文件和子目录,不然会无法访问其他文件的错误,配置代码如下:

思路二:仅根目录反向代理http://feeds.feedburner.com/huxuan,其他非根目录(根目录下的文件和子目录)都用正则匹配反向代理至http://feeds.feedburner.com

以上两种方法均经过验证,思路一简洁一些,思路二直接一些,如有问题欢迎交流。

A recommended kind of RSS solution

Today I want to recommend a kind of RSS solution and  it’s just what I use for my blog.

In this way, we will have a permanent and unique rss url. As for me, it’s http://feeds.huxuan.org/huxuan

1)Sign up as the same name for your feed in FeedSky & FeedBurner.

e.g. I have
http://feed.feedsky.com/huxuan for FeedSky &
http://feeds.feedburner.com/huxuan for FeedBurner
(I just have it for example, Please don’t subscribe my blog through this two address)

2) Use the Domain Binding Service which Feedburner & Feedsky both provide to host the feed by your own domain name

You should choose only one of the two & Feedburner is recommended absolutely
You need to create a CNAME entry in the DNS records here
More information are provided by Feedburner & Feedsky when you configure the Domain Binding Service

3) Change the feed source you didn’t choose in step 2

e.g. I choose Feedburner to create the feed, so I change the feed source of Feedsky just into http://feeds.huxuan.org/huxuan.

4)Change the default rss url of wordpress

In the header.php of theme we use, similar code can be found like this:

Change the url with underline into the feed you have created.

5)Change all possible default feed url on the site

There may be many default feed url list on the site most presenting as a link of an image or some else.
Just search for it and change it!

Attention: Some Errors happen in Step 6. Ignore it now.

6)Redirect the default feed url to the new one just in case

Insert the code below to .htacess which located in the main directory

7)Now all steps is done, just share your unique & permanet feed url to your friends

if one of the two feed service providers don’t work, just change to the other one via repeating Step 2 & 3

P.S. If there’s any error or problem, please feel free to inform me of that.