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

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

php 获取页面内容

function get_contents($url){     if(function_exists('file_get_contents')){       &nbs...

php 使用curl模拟登录discuz以及模拟发帖

<?php $discuz_url = 'http://127.0.0.1/discuz/';//论坛地址 $login_url = $discuz_url .'logging.php?action=login...

PHP分页函数仿Google分页

/**  * 分页函数  * @param int $total    总页数  * @param int $pagesize 每页几条 &n...

php登录函数login session+mysql

<?php // 为php和mysql剔除不安全html代码。 //http://blog.ddian.cn function safestrip($string){    $string = strip_tags(...

php简单分页类

<?php class page{            public $page; //当前页     publi...

jQuery UI 使用入门

jQuery UI 使用入门

 最近项目中使用了一些插件来做页面,这里把jQuery UI的使用分享出来,希望 对新手有帮助。文章结尾附源码下载。1 jQuery UI        有时你仅仅是为了实现一个渐变的动画效果而不得不把javascrip 重新学习一遍然后书写大量代码。直到...

发表评论

访客

看不清,换一张

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