Nginx 反代 Google 有一个很方便的插件 ngx_http_google_filter_module
,本文介绍其的使用方法。
所需准备
这个部分请参看之前的 基本篇
当以上准备完毕后,开始吧!
Nginx 的配置
为了方便的实现对 Google 的反代,我们需要以下两个 module
:
将这两个模块添加进 Nginx
# 下载模块 git clone https://github.com/cuber/ngx_http_google_filter_module git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module # 编译进去 ./configure / --prefix=.../ / --add-module=.../ngx_http_google_filter_module / --add-module=.../ngx_http_substitutions_filter_module # 替换 Nginx 二进制文件 cp ../sbin/nginx ../nginx.bak cp ./objs/nginx ../sbin/
这样,模块就添加完成了
Nginx 的配置文件
接下来就要进入配置文件 nginx.conf
的编辑
server { listen 监听端口; server_name 你的域名; # 为了安全考虑(例如 IP 被墙),强烈建议使用 HTTPS ssl on; ssl_protocols TLSv1.2; ssl_certificate ~/站点证书 ssl_certificate_key ~/站点证书密钥 location / { #谷歌搜索 google on; #谷歌学术 google_scholar off; #语言偏好 google_language "zh-CN"; #指定任何搜索引擎都不允许爬取此镜像 google_robots_allow off; } }
然后重新加载你的 Nginx,就可以访问你的域名看看效果了。
转载请注明:逗比根据地 » Nginx 反代 Google(插件篇)