前言
当本站谷歌镜像都无法访问时,或无法忍受界面上的广告时(广告维持本站的服务器费用:>),那么搭建一个自己的镜像就很有必要,本文以反向代理谷歌为示例,大家也可以尝试反向代理学术,油管,推特等。
搭建所需
1.一台没被墙的虚拟服务器(vps)
服务器推荐:vultr
2.服务器连接工具( XShell、PuTTY等)
工具下载:提取码:yzd5
所需依赖包
1.nginx
2.pcre 正则
3.ngx_http_proxy_module 反向代理
4.ngx_http_substitutions_filter_module 多重替换
环境部署
本教程在centos6系统下进行
-->下载 pcre
wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz"
-->下载 openssl
wget "https://www.openssl.org/source/openssl-1.0.1j.tar.gz"
-->下载 zlib
wget "http://zlib.net/zlib-1.2.8.tar.gz"
-->下载 filter扩展
1 git clone https://github.com/cuber/ngx_http_google_filter_module 2 git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
-->解压缩
1 tar xzvf nginx-1.7.8.tar.gz 2 tar xzvf pcre-8.38.tar.gz 3 tar xzvf openssl-1.0.1j.tar.gz 4 tar xzvf zlib-1.2.8.tar.gz
-->设置编译选项
cd nginx-1.7.8
./configure \
--prefix=/opt/nginx-1.7.8 \
--with-pcre=../pcre-8.38 \
--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
sudo make install
-->修改配置方式
sudo /opt/nginx-1.7.8/sbin/nginx
vi /opt/nginx-1.7.8/conf/nginx.conf
-->配置一(可选)只修改<你的域名或ip>即可,没有域名可以使用vps的ip地址。
server { server_name <你的域名或ip>; listen 80; resolver 8.8.8.8; location / { google on; } }
-->配置二(可选)ssl证书提高了镜像的稳定性。
server { server_name <你的域名或ip>; listen 443; ssl on; ssl_certificate <你的证书>; ssl_certificate_key <你的私钥>; resolver 8.8.8.8; location / { google on; } }
-->使用Esc+:wq保存并退出vim编辑器
-->重启nginx使反代生效
sudo /opt/nginx-1.7.8/sbin/nginx -s reload
至此你就搭建好了属于你的私人谷歌镜像。http://ip
即可访问你的谷歌镜像