一、環境准備
我們需要一個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
}
}
|