当前位置:首页 > 技术文档 > 正文内容

Nginx反向代理Google扩展ngx_http_google_filter_module

admin8年前 (2017-08-19)技术文档2449

模块介绍

ngx_http_google_filter_module 是一个过滤器模块,能够让谷歌镜像更便捷的部署。内建了正则表达式、URI locations和其他复杂的配置。原生nginx模块确保了更加高效地处理cookies, gstatic scoures和重定向。

最近发现之前搭建的《Nginx发现代理Google》不好用,查找方法发现一个更好方法,直接安装Nginx模块即可。

地址:https://github.com/cuber/ngx_http_google_filter_module

(或者也可以选择nginx官网源码安装:http://nginx.org/en/download.html)

模块介绍

ngx_http_google_filter_module 是一个过滤器模块,能够让谷歌镜像更便捷的部署。内建了正则表达式、URI locations和其他复杂的配置。原生nginx模块确保了更加高效地处理cookies, gstatic scoures和重定向。

安装Nginx

使用《OneinStack》Nginx选择y,其余n

重新编译Nginx,安装ngx_http_google_filter_module模块

git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_modulecd /root/oneinstack/src
git clone https://github.com/cuber/ngx_http_google_filter_module
wget http://mirrors.linuxeye.com/oneinstack/src/pcre-8.38.tar.gz
wget http://mirrors.linuxeye.com/oneinstack/src/openssl-1.0.2h.tar.gz
tar xzf pcre-8.38.tar.gz
tar xzf openssl-1.0.2h.tar.gz
tar xzf nginx-1.10.1.tar.gz
cd nginx-1.10.1./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module \--with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module--with-http_realip_module --with-http_flv_module --with-openssl=../openssl-1.0.2h \--with-pcre=../pcre-8.38 --with-pcre-jit --with-ld-opt='-ljemalloc' \--add-module=../ngx_http_google_filter_module \--add-module=../ngx_http_substitutions_filter_module
make
mv /usr/local/nginx/sbin/nginx{,_`date +%m%d`}  #备份现有nginx
cp objscp objs/nginx /usr/local/nginx/sbin/  #更新nginx

nginx -t  #检查nginx语法

/usr/local/nginx/sbin/nginx //启动
/usr/local/nginx/sbin/nginx -s reload   //重启

更改配置文件



vi /usr/local/nginx/conf/vhost/demo.linuxeye.com.conf,保持内容如下:

server {
listen 443 ssl http2;
server_name sea.yuyunhe.cn;

    listen 443;
    ssl on;
    ssl_certificate   /cert/sea.yuyunhe.cn/214232195260891.pem;
    ssl_certificate_key  /cert/sea.yuyunhe.cn/214232195260891.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
location / {
google on;
google_scholar on;  #google_scholar 依 赖于 google, 所以 google_scholar 无法独立使用。由于谷歌学术近日升级, 强制使用 https 协议, 并且 ncr 已经 支持, 所以不再需要指定谷歌学术的 tld
google_language en;  #语言偏好,默认使用 zh-CN (中文)
}
}

server {
listen 80;
server_name demo.linuxeye.com;
rewrite ^(.*)$ https://$host$1 permanent; #访问http跳转至https
}
保持配置文件重启nginx:
/usr/local/nginx/sbin/nginx -s reload

测试:

预览地址:https://sea.yuyunhe.cn

image.png

分享到:

扫描二维码推送至手机访问。

版权声明:本文由云河空间发布,如需转载请注明出处。

本文链接:http://yuyunhe.cn/index.php/post/241.html

分享给朋友:

“Nginx反向代理Google扩展ngx_http_google_filter_module” 的相关文章

Zend Studio 8打开utf-8文件出现乱码解决方法

Zend Studio 8打开utf-8文件出现乱码解决方法

今天安装了zend studio 8.0.1,运行了一个PHP程序项目(项目文件编码为utf-8),发现utf-8文件中的中文全部变成乱码了,后面终于经过寻找探索,找到了问题所 在:虽然你的项目是UTF-8编码文件,但是当通过zend studio工具运行打开时,是以工具里设定的GBK编码...

图文解说Navicat使用ssh方式连接远程MySql服务器

图文解说Navicat使用ssh方式连接远程MySql服务器

如何使用Navicat 8.0 for MySQL连接公司服务器的数据库,但我也是第一次接触这个软件,搞了半天也没连上,在网上找了很多解决的办法,其中就有使用ssh方式连接的,但写的不够详细,因此还是费了一番功夫,自己搞定的,不敢独享,特记录下来 与大家分享。首先,在Navicat的连接设置里选择S...

wamp下虚拟主机的配置

1  编辑httpd.conf,查找Include conf/extra/httpd-vhosts.conf,把前面注释符号“#”删掉。 2  编辑httpd-vhosts.conf,我把WAMPServer安装在D:/wamp,所以我这里的路径是D:\wamp\Apache2\...

PHP实现登陆后台限制到只允许一台机器在线

方法一:# <?php# ob_start();# session_start();# class CC{#   private $REFURL="http://www.php100.com";    //登陆成功后转换页面#   private $LoginFLAG=fa...

PHP利用Curl模拟登录并获取数据例子

PHP利用Curl模拟登录并获取数据例子

几乎所有的程序员来模仿用户登录或抓取数据都会使用到curl函数,下面我来给各位介绍利用curl函数实现登录并抓取数据,希望下面例子对各位有帮助。PHP的curl()在抓取网页的效率方面是比较高的,而且支持多线程,而file_get_contents()效率就要稍低些,当然,使用curl时需要开启下c...

wamp虚拟主机配置

1、首先打开apache的配置文件httpd.conf,并去掉#Include conf/extra/httpd-vhosts.conf前面的#,启用虚拟主机功能2、先把localhost配置好,免得以后访问localhost出现问题,我的wamp项目根目录是D:\wamp\www。将下面信息添加到...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。