简述 GFWInterceptor PHP 服务器端安装

g_f_w

2010/12/14 更新,适用于 api-proxy-php-0.5.zip,步骤简化了很多,推荐使用

0,服务器环境要求

服务器最好运行 Linux / FreeBSD 等操作系统,需要使用 apache httpd(nginx 有专用版本,请直接往下看),并且启用了 mod_rewrite,PHP 启用了 cURL支持。

1,下载/解压缩源代码

下载源代码压缩包:http://gfwinterceptor.googlecode.com/files/api-proxy-php-0.5.zip,解压后将 api-proxy-php 目录中的所有文件上传 / 移动到服务器相应目录。

2,文件配置

将 ~htaccess 文件改名为 .htaccess,之后用编辑器打开 users.config,按照文件中示范的每行一个用户名密码,用分号分隔的格式填入允许访问服务器的用户名密码。

不过需要注意的是,在默认 mime 情况下,apache 会把 users.config 当作文本文件,也就是说别人在浏览器输入 your.server/users.config 可以直接看到你的用户密码配置文件!临时解决办法是修改 index.php 第六行

$file_handle = fopen(“users.config”, “rb”);

中的 users.config 位置,最好放到 http root 以外,比如改成 /home/gkp/gfw/users.config,之后把 users.config 移动到相应的位置就可以了。

3,开始使用吧

安装好 GFWInterceptor 的 iDevice 上进入 Settings –> GFWInterceptor,将主力服务器设置成你安装 PHP 服务器端文件的地址,注意开头的 http:// 不要省略。在相应的位置填入上一步 users.config 中设定的用户名和密码,之后 respring 一下,打开 twitter for iPhone, Facebook, Foursquare 等应用试试看吧,没有问题的话应该可以顺利登录了。之后打开 safari,试试看 m.twitter.com,应该也是可以访问的。

4,有问题?

当安装 php-server 出现问题时,首先查看下 apache 的日志文件,如果都是类似于 File does not exist: /var/www/html/1 这样的报错的话,应该是 url rewrite 没有正常工作,请检查 apache 的 mod_rewrite 和 php-server 目录下面的 .htaccess 文件。

5,适用于 nginx 的版本

适用于 nginx 的 php 服务端程序目前还不支持用户名密码验证,安装方法如下:

  • 下载 http://gfwinterceptor.googlecode.com/files/api-proxy-php-ngix-0.4.zip,并解压缩
  • 把 api-proxy-php-ngix 目录下的文件上传/移动到服务器相应目录
  • 把 gic 这个虚拟主机配置文件放到 nginx 会自动 include 的目录中,并编辑之,根据实际情况修改域名,文档目录等选项,最后重启 nginx。
  • 搞定!

以下为老版本 php server 安装步骤,已经失效,仅供参考。

首先非常感谢 @overboming 同学连续两个晚上和我调试 GFWInterceptor 的 PHP 服务端,而且今天后来很长一段时间都是因为我的一个操作失误导致的错误,实在是很对不住 @overboming 同学,具体的这个操作失误在最后会提到,先来简单说一下安装的过程。

1,下载源代码

有两种方式,使用 svn:

svn checkout https://gfwinterceptor.googlecode.com/svn/trunk/api-proxy-php

或者直接到下面这个地址下载 index.php 和 .htaccess 这两个文件的 raw file

http://code.google.com/p/gfwinterceptor/source/browse/#svn/trunk/api-proxy-php

其中 svn 还是强烈推荐的,虽然文件可能要移动一下,不过这样可以确保在 copy / paste 时候不出错误。

2,代码安装

GFWInterceptor 的安装还是十分简单的,首先确认你的服务器使用的是 Apache httpd,并且开启了 mod_rewrite 支持,php 方面需要有 cURL 模块。没问题的话,把 index.php 和 .htaccess 这两个文件放到服务器的某个目录就可以了,完全不需要进行代码修改以及权限设置。

3,测试安装

 

首先在电脑上用浏览器打开一下 GFWInterceptor PHP server 所在的目录,看看有没有报错信息,显示白板一块就对了。如果报 error 500 internal server error 服务器内部错误的话,很可能是你的服务器 Apache 没有启用 mod_headers。如果你有操作 apache 权限的话,直接

sudo a2enmod headers

加载 mod_headers 的配置文件,并重新启动 Apache 即可。如果服务器不是你的话,那你只能退而求其次,将 .htaccess 中下面这段删掉了,副作用是 4sq 无法 check-in,facebook 无法登陆。不过你可以将备用服务器(图床服务器)保留默认的 appspot.com 地址,0.61 以后版本的 GFWInterceptor 会将 4sq check-in 之类的请求直接走备用服务器。

#<Files ~ "*.php">
SetEnvIf content-type ([^m].*) NEW_CONTENT_TYPE=$1
SetEnvIf content-type (multipart/form-data)(.*) NEW_CONTENT_TYPE=multipart/form-data-alternate$2 OLD_CONTENT_TYPE=$1$2
RequestHeader unset content-type
RequestHeader append content-type %{NEW_CONTENT_TYPE}e env=NEW_CONTENT_TYPE
#</Files>

4,开始使用吧

安装好 GFWInterceptor 的 iDevice 上进入 Settings –> GFWInterceptor,将主力服务器设置成你安装 PHP 服务器端文件的地址,注意开头的 http:// 不要省略。图床服务器则根据个人情况,有 mod_headers 的话完全也可以用自己的服务器。之后确认第一个选项在启动状态,保存退出,我这里需要 respring 一下,但是据 @overboming 说他那里则不用。

依次打开 twitter for iPhone,4sq,Facebook 试试看吧,目前这三个应用除了 4sq check-in 后的 mayor 皇冠等几个图片不能显示外,应该已经完美了。

5,关于安全

首先我认为所有 Fuck-GFW 的服务都应该保持 private,所有公开的服务都会在瞬间被干掉,经过我的实测,北京移动 edge 用户已经无法访问 GFWInterceptor 的默认 appspot 服务器了。所以我强烈建议自己搭建 GFWInterceptor 服务器的用户也将服务器保持私有状态,仅限自己和好友使用。更何况现在 GFWInterceptor 的服务端还没有验证机制,也就是说任何人只要知道你的服务器地址就可以用。大家可以将服务器路径设置的诡异一些,有条件的甚至可以在非标准端口上开一个虚拟主机,这样被猜到的可能性就大大降低了。

不过 @overboming 已经确认在下个大升级中将加入 token 验证机制,手机端转发请求时将在 HTTP_HEADER 中包含一个 token,服务器端收到后会先验证 token,没有问题才放行,届时安全性将大大改善。

最后一个建议,就是尽量使用 https 加密连接,twitter for iPhone 已经是全 OAuth,但是最新的 Facebook 登录时密码还是明文发送的,存在被居心不良的人截获的可能性。

最后说下我今天晚上犯的错误吧,我是直接在 Chrome 中复制代码,然后到 iterm 中 vi 粘贴,结果不小心在代码开头的 <? 前面多复制了一个空行,导致 twitter / Facebook 报告 xml 数据前有垃圾数据,折腾了好久,所以大家最好还是 svn 吧,最起码避免了复制代码出错的可能性。

基本安装就是这样,如果遇到问题可以留言或者在 twitter @gokeeper,我会尽我所能帮大家解决。

This entry was posted in 我的慵懒生活, 电脑相关 and tagged , , , , , , . Bookmark the permalink.

111 Responses to 简述 GFWInterceptor PHP 服务器端安装

  1. matrix says:

    1代越狱3.1.2测试成功。很好用。

  2. Pingback: Tweets that mention 简述 GFWInterceptor PHP 服务器端安装 | gkp's post -- Topsy.com

  3. tonnydan says:

    先越狱了再折腾

  4. Pingback: 大行報告 : : [GFW BLOG] 简述 GFWInterceptor PHP 服务器端安装 - Invest – 追渣沽!

  5. Pingback: 简述 GFWInterceptor PHP 服务器端安装 | 细节的力量

  6. Pingback: 试用 GFWInterceptor | gkp's post

  7. kratos says:

    你好,请问以下警告是什么意思?
    Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /XXX/index.php on line 51

  8. Pingback: 不吐不快

  9. Pingback: iOS使用GFWInterceptor简单教程 | Colorful Me, Color for Me

  10. Pingback: 在iphone/itouch上使用gfwintercepter fan q1ang | ::枫影居::windyshade.com

  11. myw says:

    hi,我的4sq facebook 都可以更新 可是twitbird、echofon都不能登录 知道为什么吗?

  12. ym says:

    hi.我的vps是apache server.老是安装不好cURL 模块,博主可否写篇安装curl的教程呢?

  13. ym says:

    我也运行了aptitude install php5-curl,但是在rx.brite.biz/info.php里就是没有curl的影子,真是怪事。在/etc/php5/conf.d/内有curl.ini文件,其内容为:
    # configuration for php CURL module
    extension=curl.so
    谢谢答复

  14. ym says:

    我没法确认curl.so 存在(我不知道如何确认).另外发现一件奇怪事,在/etc/php5/conf.d/内明明有curl.ini文件,见图http://i3.6.cn/cvbnm/1b/8e/2a/76a6dc828b7becfab04878646df58148.jpg,但是在在rx.brite.biz/info.php文件的additional .ini files parsed 部分的内容里却没有curl.ini列出,见图:http://i3.6.cn/cvbnm/7d/11/27/5e40cfd1b244e9983bdcea4ae69c0ac6.jpg (/etc/php5/cgi/conf.d是/etc/php5/conf.d/的快捷方式)

  15. 木鱼猫 says:

    部署了一份在gae上,完成后用pc访问显示 No, baby, no

    不知这样算不算成功?

  16. Jerry Zhang says:

    设置成功,可以发推,但是无法推图。请教。

  17. @kafaafa says:

    有没有免费的php 服务器可以用,或者收费较便宜的,求教各位

  18. Pingback: iOS使用GFWInterceptor简单教程 « 细节的力量

  19. granvals says:

    Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /home/granvals/domains/xxx/public_html/12/index.php on line 116
    请问这个问题有解决的办法吗?多谢了

  20. diablo_cz says:

    20101209,NP盒瓶奖颁奖前一天,连wifi也无法通过GFWinterceptor登陆twitter了,更别提移动设备的蜂窝数据。不管是自带的waytosing还是自建的appspot,均不给力。

  21. 菲比 says:

    博主好,搭PHP sever我这边提示:The server can not find the requested page:
    173.321.1.XX/iOS/ (port 80) (前面是我的主机)
    Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.8e-fips-rhel5 mod_python/3.3.1 Python/2.4.3 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at 173.231.1.12 Port 80
    请问这是什么情况呢?谢谢指导

  22. ww says:

    我的页面打开500。空间后台有cPanel,请问如何启用mod_headers?谢谢。

  23. Pfau says:

    Appspot貌似是全线阵亡了。奇怪的是我自己搭的现在又开始不正常了。

    主机上的文件版本是0.5,删除了原来的.htaccess,把~htaccess改了名儿。按照user.config里面的格式加了用户名。

    打开浏览器页面,白板。用iOS设置了,刷啥都是无法访问。

  24. sting says:

    我在自己的php空间中上传了最新的代码,翻墙无效,自带的appspot也无效了,GFW发威了?

  25. gsdv says:

    能帮我看看我的问题吗 ? 谢谢 http://tt.biz.uz/i/
    如果删除 #<Files 段后会提示 index.php line xxx error 之类的
    是免费空间。如果确定是空间不支持我就放弃了。

  26. gsdv says:

    我在ios上改host后appspot可以用了,但是只能http,使用https还是打不开。ip是ping google。cn来的。是不是改host都不能用https了?

  27. ww says:

    白板了,还是不起作用。我查看页面源代码,什么都没有,大小也是0,是不是没有加载?

    另外,在GFWInterceptor设置的主力服务器下边用户名和密码那里我现在是空着,这样做对吗?

    • ww says:

      最近的几条错误信息都是
      [Fri Dec 10 20:24:26 2010] [error] [client 66.220.147.248] File does not exist: /home/ww03/public_html/403.shtml

      我想和它没什么关系吧?

  28. Double says:

    如果你有操作 apache 权限的话,直接

    sudo a2enmod headers

    加载 mod_headers 的配置文件,并重新启动 Apache 即可。

    上面这段操作完全不会,使用的是site5的空间,放上以后用浏览器浏览出现500错误,就不知道怎么下手了。请教如何加载配置文件并重新启动apache。谢谢

    • brad says:

      我和你显示的一样,也是这个错误,不知道为什么?昨天晚上搞了一个晚上没有成功,不知道是不是我的主机问题啊。

  29. @dunduncat says:

    [11-Dec-2010 00:21:36] PHP Warning: Cannot modify header information – headers already sent by (output started at /home4/diyangor/public_html/api/index.php:128) in /home4/diyangor/public_html/api/index.php on line 130
    请问这个该如何解决啊?
    谢谢

  30. Ryan says:

    我的iphone上翻不过去了。。如何能让gfwinterceptor再次好用呢

  31. sting says:

    搞定了,大家把users.config填上自己的帐号密码,在GFWIntercepter的网址配置下方也填入,我已能用自建php空间正常翻墙。

  32. mimu says:

    twitter访问的时候error_log显示 File does not exist: /var/www/html/1是为什么啊?
    但是拿浏览器访问twitter.com可以跳到mobile.twitter.com能访问

  33. snfoew says:

    登录到我的php空间里有三个文件夹:confidential、cwphp、htdocs,我应该上传到哪个文件夹下面啊。
    好几年没玩过空间了,刚申请的

  34. Pingback: iOS使用GFWInterceptor简单教程 | Colorful Me, Color for Me | IPhone

  35. Andy says:

    貌似0.5版仍然需要Apache加载mode_headers才行?

    该死的Godaddy Linux Shared Hosting不知道到底支持不支持mode_headers,google了半天也不能确定,发了service ticket给Godaddy也半天不见回。

    Facebook不能走GFWinterceptor很不爽啊~

  36. Andy says:

    Godaddy的客服邮件确认了Shared Hosting不支持SetEnvIf指令(免费的当然也不支持吧?)

    请问
    SetEnvIf content-type ([^m].*) NEW_CONTENT_TYPE=$1
    SetEnvIf content-type (multipart/form-data)(.*) NEW_CONTENT_TYPE=multipart/form-data-alternate$2 OLD_CONTENT_TYPE=$1$2
    可有其他解决方法?
    不懂PHP掩面泪奔。。。

  37. HJin_me says:

    问个问题~
    我是lnmp环境,设置好了之后,twitter OK了,但是 facebook 访问不了。
    自己翻看了一下日志
    服务器路径是 xxxx,然后 rewrite 成 xxxx/index.php,访问facebook 的时候,就变成了 xxxx/index.php/login.php?=… 服务器上面没有 login.php 文件,于是 nginx 提示 No input file specified.
    求助一下这个应该怎么办,nginx 的配置应该怎么改?

    location ~ .*\.(php|php5)?$
    {
    fastcgi_pass unix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fcgi.conf;
    }

  38. LIN says:

    请问,登录到我的php空间里有三个文件夹:domains、imap、public_html,我应该上传到哪个文件夹下面?完全不懂PHP的人求教~

  39. HJin_me says:

    来扰了~~
    问个事情。启用了 gfwinterceptor 之后
    instagram(搜索周边地理位置的时候) 还有 4sq 里面的中文都是乱码……
    开VPN 的话,就一切正常……

    能确定是什么问题吗?或者怎么改改源代码来调试这个问题

  40. xplorer says:

    Debian 5 的 VPS 使用了 0.6 版的 PHP 脚本有问题。
    error.log 显示错误信息:
    .htaccess: Invalid command ‘RequestHeader’, perhaps misspelled or defined by a module not included in the server configuration
    请问:这个是什么意思?应该如何解决?谢谢。

  41. brad says:

    [11-Feb-2011 10:48:42] https://api.twitter.com/1/statuses/home_timeline.xml?count=100&include_entities=true
    [11-Feb-2011 10:48:42] https://api.twitter.com/1/account/apple_push_destinations.xml
    [11-Feb-2011 10:48:43] https://api.twitter.com/1/statuses/home_timeline.xml?count=100&include_entities=true
    [11-Feb-2011 10:48:43] https://api.twitter.com/1/account/apple_push_destinations.xml
    [11-Feb-2011 10:48:43] https://api.twitter.com/1/statuses/mentions.xml?count=20&include_entities=true
    [11-Feb-2011 10:48:44] https://api.twitter.com/1/statuses/mentions.xml?count=20&include_entities=true
    [11-Feb-2011 10:48:45] https://api.twitter.com/1/direct_messages.xml?
    [11-Feb-2011 10:48:45] https://api.twitter.com/1/direct_messages/sent.xml?
    [11-Feb-2011 10:48:46] https://api.twitter.com/1/account/settings.xml
    [11-Feb-2011 10:48:46] https://api.twitter.com/1/statuses/home_timeline.xml?count=100&include_entities=true
    [11-Feb-2011 10:48:46] https://api.twitter.com/1/direct_messages.xml?
    [11-Feb-2011 10:48:46] https://api.twitter.com/1/direct_messages/sent.xml?
    [11-Feb-2011 10:48:47] https://api.twitter.com/1/account/settings.xml
    [11-Feb-2011 10:48:47] https://api.twitter.com/1/statuses/home_timeline.xml?count=100&include_entities=true
    [11-Feb-2011 10:49:01] https://api.twitter.com/1/wangzhonghao/lists.json?cursor=-1
    [11-Feb-2011 10:49:01] http://api.twitter.com/1/help/test.json
    [11-Feb-2011 10:49:01] https://api.twitter.com/1/saved_searches.json
    [11-Feb-2011 10:49:01] https://api.twitter.com/1/users/show/wangzhonghao.json
    [11-Feb-2011 10:49:02] http://search.twitter.com/trends/current.json
    [11-Feb-2011 10:49:02] https://api.twitter.com/1/wangzhonghao/lists/subscriptions.json?cursor=-1
    [11-Feb-2011 10:49:03] https://api.twitter.com/1/saved_searches.json
    [11-Feb-2011 10:49:05] https://api.twitter.com/oauth/access_token

    在目录里面多了一个错误文件error_log,里面就是这样显示的,我昨天搞了一个晚上也没有成功,我是严格按照教程搞的,不知道为什么会这样,难道我的空间不知道吗?我的是收费空间。请教博主,谢谢

  42. dingtianran says:

    大哥求助啊求助
    mod_headers mod_rewrite已确认打开
    index.php大白屏没错
    但是twitter还是不行
    看error.log是一排File does not exist: /var/www/api-proxy-php/1
    是.htaccess的原因吗 没啥可改的呀

  43. Lucy says:

    你们的是不是要新些啊?为什么我完全找不到哪里可以“在相应的位置填入上一步 users.config 中设定的用户名和密码”的地方

  44. shunketsu says:

    為什麼 我設置好了 手機刷 twitter 提示 start tag expected 怎麼也用不了~!

  45. A&G says:

    我用gofreeserve的免费服务器建了一个php空间,按我使用的情况应该是正常了,因为我自己添加的两个被封的域名现在可以使用了,但是让我无语的是facebook app和 teitter app 都不能连接,甚至我用safari打开fb、teitter的网站都是空白的

  46. 我iPad上装的GFWInterceptor就没发现可以填用户名密码的地方呀……请问这是哪个适用于哪个版本的?

  47. leo says:

    请问一定要是国外的服务器吗 国内的可以吗

  48. 大戒 says:

    请教博主:
    我按步骤,不知如何设置:users.config 里面的用户名和密码,格式怎样?分号在哪里?
    所以,打开http://yuming.com/gfw..是空白页?无法继续,(我的文件放在gfw里)?
    我看到多了一个error的文件。。。
    谢谢

  49. イタチ says:

    已经折腾三天了。。。还是搞不定。。。
    买了个VPS。。。借用了个域名。。。让VPS提供商把设置都调到上文里说到的了。。。
    可是上m.twitter.com、dropbox.com等关键词网站时要么是空白一片要么是Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /www/web/ceshi1/public_html/index.php on line 157
    安全模式关了、open_basedir也关了啊。。。。
    gkp大神您出手相助一下吧。。。。

  50. peter says:

    万能的主啊,谢谢你吧这么优秀的开发人员带到我们身边 阿门

  51. chapiom says:

    有人试过dropbox吗,我这里除了dropbox其他都正常

  52. Pingback: 简述 GFWInterceptor PHP 服务器端安装 « 资料库

  53. Pingback: iTouch 4的越狱与翻墙 « LorDong's Blog

  54. Pingback: iTouch 4的越狱与翻墙 - Life Share-残月刀个人独立博客

  55. Pingback: iTouch 4的越狱与翻墙 « 细节的力量

  56. demosses says:

    不好意思不好,我完全是个菜鸟,能不能问一下这个是什么问题,怎么解决?
    PHP Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /home/u140227251/public_html/index.php on line 157

  57. @flyfishcyx says:

    我也是报错
    貌似是GODADDY的付费空间
    [17-Jul-2011 09:47:41] PHP Warning: Cannot modify header information – headers already sent by (output started at /home/flyfishc/public_html/ios/index.php:168) in /home/flyfishc/public_html/ios/index.php on line 170

  58. yoxu says:

    The server encountered an internal error or misconfiguration and was unable to complete your request.
    这是哪里的问题?

  59. chenjx says:

    nginx版本怎样才算搭建成功呢?访问地址出现 No input file specified. 是什么原因呢?

  60. kidd says:

    overboming;malicyes;hello

    用户名,密码,怎么有三个部分

  61. Pingback: 最近使用的跟Twitter有关的几个小应用 | Due Care, Due Diligence

  62. Pingback: openvpn 安装 client端ipone itouch(外篇)GFWInterceptor | 鼻涕牛

  63. Pingback: GFWInterceptor-爬墙用户的福音(iPhone/touch/ipad)

Leave a Reply to gsdv Cancel reply

Your email address will not be published.