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

Nginx反向代理Google扩展ngx_http_google_filter_module

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

模块介绍

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

分享到:

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

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

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

分享给朋友:

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

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

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

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

php二维数组转换为一维数组的几种方法

在开发过程中,我们经常需要将二维数组转为一维数组,个人总结了2种方法,分享给大家如何将下面的二维数组转为一维数组。复制代码 代码如下:$msg = array(  array(    'id'=>'45',    'name'=>'...

PHP开发之THINKPHP多表联合查询操作的三种方法

THINKPHP 中关联查询(多表查询)可以使用 table() 方法或和join方法,请看示例: 联合查询         1、原生查询    &...

浅谈 PHP 与手机 APP 开发(API 接口开发)

文章转载自:http://www.thinkphp.cn/topic/5023.html这个帖子写给不太了解PHP与API开发的人一、先简单回答两个问题:1、PHP 可以开发客户端?答:不可以,因为PHP是脚本语言,是负责完成 B/S架构 或 C/S架构 的S部分,即:服务端的开发。(别去纠结 GT...

TP 查询缓存

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

php取整函数ceil,floor,round,intval函数的区别

开发过程中,遇到数据处理取整的时候,你会用哪个呢,小涛来介绍一下:PHP取整函数有ceil,floor,round,intval,下面详细介绍一下:1、ceil — 进一法取整说明float ceil ( float $value )返回不小于 ...     ...

发表评论

访客

看不清,换一张

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