一、环境准备
我们需要一个nginx的模块来进行设置,ngx_http_google_filter_module。前提我们是有一个海外的VPS,并且可以访问谷歌,我的VPS是亿速云香港的。
首先先感受一下我的成果吧,请点击http://google.qinyj.top
二、软件安装
我的操作系统是CentOS 6.x 64位操作系统,最下面有我编译好的nginx,如果为了快速搭建的话,直接使用我编译好的二进制程序和配置文件,几分钟就可以搞定。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
cd
/root/
wget http:
//nginx
.org
/download/nginx-1
.7.8.
tar
.gz
git clone https:
//github
.com
/cuber/ngx_http_google_filter_module
git clone https:
//github
.com
/yaoweibin/ngx_http_substitutions_filter_module
tar
xzf nginx-1.7.8.
tar
.gz
cd
nginx-1.7.8
.
/configure
\
--prefix=
/usr/local/nginx
\
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=
/var/tmp/nginx/client/
\
--http-proxy-temp-path=
/var/tmp/nginx/proxy/
\
--http-fastcgi-temp-path=
/var/tmp/nginx/fcgi/
\
--http-uwsgi-temp-path=
/var/tmp/nginx/uwsgi
\
--http-scgi-temp-path=
/var/tmp/nginx/scgi
\
--with-pcre \
--add-module=
/root/ngx_http_google_filter_module
\
--add-module=
/root/ngx_http_substitutions_filter_module
make
make
install
|
三、配置nginx
1
|
vim
/etc/nginx/nginx
.conf
|
在http模块里面增加如下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
upstream google {
server 173.194.38.1;
server 173.194.38.2;
server 173.194.38.3;
server 173.194.38.4;
#通过dig -t A www.google.com获取谷歌的IP地址
}
server {
resolver 8.8.8.8;
location / {
google on;
#启用谷歌镜像功能
#google_scholar on; #启用谷歌学术搜索,可以不设定
#google_robots_allow on; #允许蜘蛛爬镜像站点,可以不设定
google_language en;
#设定语言,不设定默认是中文
#设定谷歌的语言,语言可以自己随意定义,支持的语言请看附录
#google_ssl_off "google"; #不适用https访问
}
}
server {
listen 80;
server_name google.qinyj.top;
#好像是填写什么域名,域名就无法访问
location / {
proxy_pass http:
//google
;
#反向代理到upstream
}
}
|