September 22 2011

Google App Engine – HTTP Proxy Server

This is merely a translated (Chinese) version of “How to setup your own proxy server in 5 minutes for free
More can be found on http://www.labnol.org/
In addition, temporary solutions are presented here (in the end in English) to some frequently occured problems which are not given in the original post, so are some common issues related to the basic operations concerning GAE.

 

正如我之前所说的,翻译和整理是这篇文章的主要部分,虽然我比较倾向于仅仅在这块私人领域留下我个人所想到的,而非所谓的也是一味的的转贴。。。
写这篇Post有几个目的,首先,基于这个idea来建立Proxy Server的帖子实在很多,尤其是中文的,不过部分文章直接使用appcfg.py来进行上传更新等操作,给从未接触过python环境的用户带来了不便。
其次,原文作者在youtube上发布了详细的架设说明,不过基于目前大陆的封锁状况,咳咳。
最后,提供了一些简单的(非技术性的)针对一些常用问题的解决方法以及少许的个人评价。

 

C’est parti.
1. 用你的gmail帐号登录https://appengine.google.com/
2. Create Application
3. 输入你想使用的子域名(也就是你的Application Identifier),免费用户的App都被host在appspot.com 域上 ex. abc.appspot.com 至于Appication Title则可以随意
4 从http://www.python.org/下载并安装python
5. 从http://code.google.com/下载Google App Engine SDK for Python
6. 从http://img.labnol.org/files/proxy.zip下载并解压
7. 启动GAE SDK, 在Edit-Preferences处分别填入

i. 你的Python安装路径 Typically …\Python2?\python.exe

ii. 你的GAE SDK安装路径 Typically …\Google\google_appengine

iii. 任意一个文本编辑器的路径 wordpad或者notepad++ whatever

8. File-Add Existant Application 选择proxy.zip的解压路径
9. 单击edit打开文本编辑,将第一行application:后的内容换成你的Application Identifier (只需要.appspot.com之前的部分即可) 并保存
10. 一切就绪,单击Deploy即可

 

在键入了(与你的Application Identifier)对应的Google账户及密码之后,Deploy的过程有时需要很长时间,
The deployment might take several minutes (an exemple is shown below), patience is all you need.
Deploying new version.
Checking if new version is ready to serve.
Will check again in 1 seconds.
Checking if new version is ready to serve.
Will check again in 2 seconds.
Checking if new version is ready to serve.
Will check again in 4 seconds.
Checking if new version is ready to serve.
Will check again in 8 seconds.
Checking if new version is ready to serve.
Will check again in 16 seconds.
Checking if new version is ready to serve.
Will check again in 32 seconds.
Checking if new version is ready to serve.
Will check again in 60 seconds.
Checking if new version is ready to serve.
Will check again in 60 seconds.

 

However, even it is finished, you are still likely to receive the following error message:
Error 400: — begin server output —
Creating a composite index failed: This index:
entity_type: “EntryPoint”
ancestor: false
Property {
name: “last_updated”
direction: 2
}
is not necessary, since single-property indices are built in. Please remove it f
rom your index file and upgrade to the latest version of the SDK, if you haven’t
already.

 

As a matter of fact, if you try accessing abc.appspot.com (your free subdomain here), a 404 Not Found Error will probably occur.
Well, this seems to be just temporary, The problem is solved after like 2 hours of waiting (as far as I am concerned),
However, if this is not true in your case,serveral solutions based on modifying the source file can be easily found on the internet.
But you might prefer to try the following first.
– Sign in (again if necessary) using the same account https://appengine.google.com/
– In the left side bar, go to Versions.
– This should give you access to the live URI of the application deployed (probably something like http://secureable.latest.abc.appspot.com in our case), use that instead.

 

Notice: If you have done an incomplete update (which is rather possible if you force it to quit while it is on the 60s count),you might be asked to undo it before you would be able to try a second time.
This can be achieved with the help of the appcfg.py file. (documentation.)
Simply start your python shell and change the current directory to GAE main directory on your computer.
Type appcfg.py rollback <your proxy directory>,
and in the case of ipython, type %run appcfg.py rollback <your proxy directory>
Here is what your proxy should like.

 

最后,不得不说,这个代理的功能是相当有限的,他不能执行flash或者java的脚本,也就是说,你不能执行一些非常重要的操作,如登录
不过代理的速度确实很快(归功于google的服务器),非常适合在被封锁的环境下浏览网页。

咳咳,别做坏事哦=。=




Posted 22/09/2011 by Tao in category "Uncategorized

Leave a Reply