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

Nginx反向代理Google扩展ngx_http_google_filter_module

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

模块介绍

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” 的相关文章

php获取从百度搜索进入网站的关键词

<?php    function search_word_from() {     $referer = isset($_SERVER['HTTP_REFERER'])?...

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

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

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

jQuery编程的最佳实践

加载jQuery1.坚持使用CDN来加载jQuery,这种别人服务器免费帮你托管文件的便宜干嘛不占呢。点击查看使用CDN的好处,点此查看一些主流的jQuery CDN地址。<script type="text/javascript" src="...

推荐一些国内的Jquery CDN免费服务

Jquery是个非常流行的JS前端框架,在很多网站都能看到它的身影。很多网站都喜欢采用一些Jquery CDN加速服务,这样网站加载jquery会更快。之前火端网络的一些网站都是使用Google的jquery CDN,如:http://ajax.googleapis.com/ajax/lib...

php利用百度地图API进行IP定位和GPS定位

最 近在做一个手机端的webapp地图应用,而核心内容当然是定位了,但是定位的话有几种方式,IP定位,GPS定位,基站定位(这个貌似webapp用不 了), 那么剩下核心的gps定位和ip定位了,我们知道,html5有定位API,但是该API拿到的GPS数据是硬件坐标,无法直接显示在地图上。...

TP 查询缓存

<?php     function cache_data($sql){             $SqlDao&nbs...

发表评论

访客

看不清,换一张

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