使用Gappproxy搭建自己的Google代理服务器

说到Gappproxy,很多人应该都已经知道,网上也有很多教程。

GAppProxy设计的初衷是为教育网用户提供一个免费的国际代理。因为它使用的是Google的服务器,Google在全球各地有自己的加速服务, 所以用它来作为代理服务器,速度相当的快,但是也有很多人违背了这个初衷,拿来作为翻墙工具。说到这里,我也不知道大家会拿来做什么用,但是希望这个对大 家有用。

网上的Gappproxy有很多教 程,比如八亿空间就有比较完整的教程,但是这些教程都是基于windows的,对于linux的初学者来说,可能就会有些吃力,所以今天根据网上的教程, 在linux下重写一遍,我使用的是ubuntu 10.04,希望ubuntu的初学者也能 follow my twitter:@jiechic 。

下面,构建这个代理服务器与使用步骤简单步骤。

1. 创建一个 Google App Engine 应用程序。
2. 下载并安装 Python 和 Google App Engine SDK并获取Gappproxy。
3. 修改一个文件,使用Google App Engine SDK上传Gappproxy。
4. 修改浏览器代理,运行客户端,开始自由冲浪!

 

第一:创建 GAE 应用程序:


http://code.google.com/intl/zh-CN/appengine/

打开以上网址,在右边的使用入门第一步中,点击注册。

在打开的网址,使用Gmail账户登录(没有Gmail的请自行申请)

然后在页面当中看打一个按钮为”Create an Application“(创建一个引用程序)

在出现的网址的Application Identifier栏目中,输入应用程序的名称,如 “google-proxy”(自行设定)。
在Application中输入程序的标题,其实也是简单的说明,比如 ”A Gae Proxy“。
点击 “Create Application”。这样就创建成功了,但是,要把应用程序的名称记住,比如刚才写的”google-proxy“。

 

第二步:安装python环境、Google App Engine SDK开发环境以及Gappproxy源码。


ubuntu 的python安装很简单,在终端中通过以下命令即可

sudo apt-get install python

接下来下载Google App Engine SDK,打开下面网址。下载 Google App Engine SDK for Python 的 linux 版本

http://code.google.com/appengine/downloads.html

解压得到 google_appengine 文件夹。
然后下载 gappproxy 的源码程序。我们通过SVN下载最新版的 gappproxy ,在截稿前,最新版是 1.2 版。在终端中输入以下命令,即可获得最新源码。(9月12日更新2.0版,更加好用)

svn checkout http://gappproxy.googlecode.com/svn/trunk/ gappproxy-read-only

这样得到一个文件夹为 gappproxy-read-only ,里面包含 gappproxy 的最新源码

2.0版到如下地址下载。须翻墙。可以代理访问试试。

http://code.google.com/p/gappproxy/downloads/list

 

第三步:修改文件,上传程序,建立代理服务器。


找到 gappproxy 的源码文件夹,修改 fetchserver 文件夹内的 app.yaml 文件。

找 到第一行”application: your_application_name“,把your_application_name改为你的程序名称,比如上文提到的“google- proxy”,注意:application的冒号后面有一空格。如没有这个空格,则会出错。

将 fetchserver 复制到 google_appengine 文件夹,在该文件夹的终端中,通过以下命令使用 Google App Engine SDK 将程序上传到 google 的服务器上去。
python appcfg.py update fetchserver/

 

第四步,设置本地客户端,使代理生效


打开 gappproxy 的源码文件夹,找到 localproxy 文件夹内的 proxy.conf 文件,配置本地客户端,找到以下字段,修改 your-fetch-server 为你的程序名称,如上文所说的 “google-proxy”。

#fetch_server = http://your-fetch-server.appspot.com/fetch.py

修改后,去掉前面的 ”#“后,修改成功后的样子为如下。

fetch_server = http://google-proxy.appspot.com/fetch.py

如果本身是使用代理上网,则根据情况修改 local_proxy 的配置,要使配置生效,则需要将前面的 ”#“ 去掉。在 localproxy 文件夹的位置终端中通过以下命令,启动代理客户端

python proxy.py

启动成功后,会有以下相似提示

HTTPS Enabled: YES
Direct Fetch : YES
Listen Addr  : 127.0.0.1:8000
Local Proxy  :
Fetch Server : http://google-proxy.appspot.com/fetch.py
--------------------------------------------

然后设置firefox的代理服务器。打开firefox的首选项——高级——网络——设置

选择手动配置代理服务器,在 SOCKS 主机处输入“127.0.0.1”(或者”localhost“),在端口中输入”8000“,确定即可使用你所架设的google代理服务器。

 

进阶设置一:智能代理


在通过以上设置后,访问所有的网页,都是通过代理服务器,但是,如果在联网的情况下,不断使用代理服务器,网速会有所下降,而且国人使用代理服务器,大多是 用来访问因为国内防火墙而无法访问的网站。所以我们需要的功能应该是,一些特别的无法访问的网站通过代理访问,而国内的大部分网站直接访问而不通过代理服 务器。

首先,将上面提到的过程中,firefox设置代理服务器的设置改为使用系统设置。

然后,给firefox添加插件autoproxy。

firefox的插件autoproxy安装之后,配置auto添加规则订阅,将gfwlist订阅。

autoproxy中默认有许多代理服务器,包括gappproxy的默认配置,我们只需要在选择代理服务器中选择gappproxy即可。

通过上面的操作,autoproxy插件会自动通过订阅的列表,当访问列表内的地址时,自动调用gappproxy代理服务器去访问,也实现了以下翻墙的功能。

 

进阶设置二:独享代理


gappproxy的代理文件为默认的”fetch.py“,只要别人通过搜索appspot.com/fetch.py,即可搜索到N个代理服务器,也包括你的,如果多人使用,则会出现一些无法使用的情况,毕竟GAE项目每天只有1G的流量。

我们要独享自己建立的代理,则需要修改服务器端的内容。例如把:url: /fetch.php 和 script: fetch.py 修改成 url: /123456.php 和 script: 123456.py 同是把目录下的 fetch.py 也改成 123456.py (注意三者名称要一致,不然出错

然后通过上文命令,把程序上传到 google 的服务器中。之后修改localproxy文件夹内的proxy.conf文件,把原来的<

http://google-proxy.appspot.com/fetch.py

修改为

http://google-proxy.appspot.com/123456.py

在运行客户端即可

python proxy.py

一些问题:


gappproxy在访问一兆以上的文件是会出错,比如通过代理服务器下载文件。如果需要解决,建议访问八亿空间,上面有详细的教程,需要看的,请点击这里

{ 发表评论? }

  1. BoKeam

    很复杂…

  2. BoKeam

    现在我一般都用SSH,很早的时候折腾过GAE的代理

  3. Firm

    不会复杂的,操作一遍就很简单了

  4. 疾风

    好复杂啊

  5. 哲哲

    谢谢提到的博客·呵呵·

  6. zhangchunlei

    mark 一下

  7. icyomik

    不顶不成吖,谢谢咯,Mark一下。

  8. Kuka

    谢谢,搭建成功

  9. haizhu

    一直在找linux下gap翻墙 找到了 ….

  10. ppseeker

    这个可以看youtube的视频了吗?twitter可以登录上去了吗?

  11. ppseeker

    这个可以登入twitter吗?可以看youtube的视频吗?

  12. Kunimore.

    请问一下,关于新的版本应该如何更新呢?
    也就是在http://code.google.com/p/gappproxy/downloads/list上边的fetchserver-2.0.0中,也只是需要同样的步骤,先修改app.yaml然后上传是么?但是这个文件夹内只有两个文件,不包含appcfg.py等,是需要替换倒1.0里边的fetchserver的同文件么?
    本人小白,未敢尝试,多谢博主.

  13. kinglee0531

    I have met such kind of problem while I install it in kubuntu.
    This is the problem I met:

    ——————————————————————————————

    Will check again in 32 seconds.
    Checking if new version is ready to serve.
    Closing update: new version is ready to start serving.
    Uploading index definitions.
    Error 400: — begin server output —
    Creating a composite index failed: This index:
    entity_type: “AccessDestination”
    ancestor: false
    Property {
    name: “counter”
    direction: 2
    }

    is not necessary, since single-property indices are built in. Please remove it from your index file and upgrade to the latest version of the SDK, if you haven’t already.
    — end server output —
    Your app was updated, but there was an error updating your indexes. Please retry later with appcfg.py update_indexes.

    —————————————————————————————-
    thx!
    Hey I follow you here , you are a great man, hope you can bear me

      • kinglee0531

        嗯,那是因为我在kubuntu上面的打字有问题,我装的这个ibus看不到输入面板,输入汉字有点难度。。。。
        回到刚才那个问题,我有重新试了一边,就是有申请了一个号,问题还是那样。。
        你看:

        Please remove it from your index file and upgrade to the latest version of the SDK, if you haven’t already.
        这个我不明白 明明是我刚刚创建的一个,怎么还会有remove the index??

        jiong !!!
        It seems that i have met the input problem…..can not input the chinese either!!
        I will do as what you said just now[face:26]

          • kinglee0531

            我安你说的作了一遍

            kinglee@ubuntu:~/Downloads/gappproxy-read-only/localproxy$ python proxy.py
            ——————————————–
            HTTPS Enabled: YES
            Direct Fetch : YES
            Listen Addr : 127.0.0.1:8000
            Local Proxy :
            Fetch Server : http://crosswall-proxy.appspot.com/fetch.py
            ——————————————–
            但是呢 靠 我的火狐装了tor-proxy。Net的插件,难道是冲突??这不能上图,一回我发给你的ubuntuforum那,麻烦你了[face:5]

          • kinglee0531

            well,well
            I made it!

          • kinglee0531

            第一次使用后一点事情都没有,然后就出现了这种情况:
            socket.error: [Errno 98] Address already in use
            kinglee@ubuntu:~$ gappproxy
            Gappproxy config exist. If Gappproxy doesn’t work, try remove directory ~/.gappproxy and restart.
            ——————–
            然后我这样作的:

            kinglee@ubuntu:~$ rm -rf .gappproxy
            kinglee@ubuntu:~$ gappproxy
            Gappproxy config doesn’t exist, now will create it.
            Creation finished, now will launch gappproxy.
            又出现了这个:

            .
            ——————————————–
            HTTPS Enabled: YES
            Direct Fetch : YES
            Listen Addr : 127.0.0.1:8000
            Local Proxy :
            Fetch Server : http://flyfree-proxy.appspot.com/fetch.py
            ——————————————–
            Traceback (most recent call last):
            File “/home/kinglee/.gappproxy/proxy.py”, line 485, in
            httpd = ThreadingHTTPServer((“127.0.0.1″, listen_port), LocalProxyHandler)
            File “/usr/lib/python2.6/SocketServer.py”, line 402, in __init__
            self.server_bind()
            File “/usr/lib/python2.6/BaseHTTPServer.py”, line 108, in server_bind
            SocketServer.TCPServer.server_bind(self)
            File “/usr/lib/python2.6/SocketServer.py”, line 413, in server_bind
            self.socket.bind(self.server_address)
            File “”, line 1, in bind
            socket.error: [Errno 98] Address already in use

            窘,[face:38][face:2]这又是怎么会是??

  14. Lin.Hj

    不知道为什么打开youtube和facebook都只能看到一个只有文字的网页,完全看不到其他东西,博主有遇到这种情况吗?

      • Lin.Hj

        谢谢博主的回复,刚才试了一下,在chrome+proxy switchy里设置auto switch mode才会出现这种情况,直接用代理打开倒是不会,囧,我短路了,不知道现在是什么情形

  15. S.W.G

    呵呵,看来看评论是有好处的,我原来在win下也自已搭建了,今天看到你这个ubuntu下用的客户端马上用到ubuntu下了,可是起不了作用,找也找不出原因.现在知道了,应该是因为我原来的fetch是用旧版的1.0而你这是用2.0制作的所以才没起作用对吧

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>