这段时间VPN不好用了,经常断续。
之前用过不少Google镜像站,可惜寿命都不长,
要是能建立一个私人Google镜像的话,也免去了绝大部分翻墙需求了。
于是,开工
首先,已经有开源项目在github上了
https://github.com/cuber/ngx_http_google_filter_module
其实部署很简单,是一个Nginx插件的形式,
但Nginx不能想Apache那样直接加载so扩展。于是,这里的问题主要就涉及到Nginx及SSL之类的编译。
先安装依赖,官方缺少c++编译环境支持,这里就先安装
1
| yum install build-essential git gcc g++ make gcc-c++
|
获取源码
1 2 3 4
| wget "http://nginx.org/download/nginx-1.7.8.tar.gz" wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz" wget "https://www.openssl.org/source/openssl-1.0.1j.tar.gz" wget "http://zlib.net/zlib-1.2.8.tar.gz"
|
克隆扩展插件
1 2
| git clone https://github.com/cuber/ngx_http_google_filter_module git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
|
解压
1 2 3 4
| tar xzvf nginx-1.7.8.tar.gz tar xzvf pcre-8.36.tar.gz tar xzvf openssl-1.0.1j.tar.gz tar xzvf zlib-1.2.8.tar.gz
|
编译安装
1 2 3 4 5 6 7 8
| ./configure \ --prefix=/opt/nginx-1.7.8 \ --with-pcre=../pcre-8.36 \ --with-openssl=../openssl-1.0.1j \ --with-zlib=../zlib-1.2.8 \ --with-http_ssl_module \ --add-module=../ngx_http_google_filter_module \ --add-module=../ngx_http_substitutions_filter_module
|
配置
1
| vi /opt/nginx-1.7.8/conf/nginx.conf
|
1 2 3 4 5 6 7 8
| server { server_name localhost; listen 80; resolver 8.8.8.8; location / { google on; } }
|
启动
1
| sudo /opt/nginx-1.7.8/sbin/nginx
|
完成,打开浏览器查看下Nginx强大的反代~
补充
Nginx 反代openresty+lua玩法
http://drops.wooyun.org/tips/6403