Nginx反向代理Google

基于Nginx扩展模块

https://github.com/cuber/ngx_http_google_filter_module/blob/master/README.zh-CN.md

0x01 安装 gcc & git

1
apt-get install build-essential git gcc g++ make

0x02 下载最新版源码

nginx 官网:
http://nginx.org/en/download.html

1
wget http://nginx.org/download/nginx-1.9.12.tar.gz

0x03 下载最新版 pcre

pcre 官网:
http://www.pcre.org/

1
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz

0x04 下载最新版 openssl

opessl 官网:
https://www.openssl.org/

1
wget https://www.openssl.org/source/openssl-1.0.1j.tar.gz

0x05下载最新版 zlib

zlib 官网:
http://www.zlib.net/

1
wget http://zlib.net/zlib-1.2.8.tar.gz

0x06 下载google扩展

1
git clone https://github.com/cuber/ngx_http_google_filter_module

0x07 下载 substitutions 扩展

1
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module

0x08 解压缩

1
2
3
4
tar xzvf nginx-1.9.12.tar.gz
tar xzvf pcre-8.37.tar.gz
tar xzvf openssl-1.0.1j.tar.gz
tar xzvf zlib-1.2.8.tar.gz

0x09 编译与安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 进入 nginx 源码目录
cd nginx-1.9.12

# 设置编译选项
./configure \
--with-pcre=../pcre-8.37 \
--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

# 编译安装
make
make install

0x10 其中http的配置方式

1
2
3
4
5
6
7
8
server {
trueserver_name <你的域名>;
truelisten 80;
trueresolver 8.8.8.8;
truelocation / {
truetruegoogle on;
true}
}