LNMP安装google反代扩展

  • 5
  • 9,680 views
  • A+
所属分类:工具资源

wen.lu的google反代早已开源,这两天折腾了一下在LNMP下如何方便的添加google反代扩展。在军哥的LNMP1.3下加载nginx扩展很方便。随手记录一下,搭建个自己的反代镜像吧!首先是安装LNMP环境,其实过程中装个nginx就行了,不过可能有别的建站需求,实际情况可以一起装。装好后开始下面的过程。

项目Github地址:https://github.com/cuber/ngx_http_google_filter_module/

#升级下系统
Debian/Ubantu系apt-get update
CentOS系yum update
# 安装 gcc & git,如果上面update成功,也有可能gcc已经安装好了
Debian/Ubantu系apt-get install build-essential git gcc g++ make
CentOS系yum install gcc gcc-c++ git make

# 下载最新版源码
#
# 下载最新版 pcre
# pcre 官网:
# http://www.pcre.org/
#
wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz"

# 下载最新版 openssl
# opessl 官网:
# https://www.openssl.org/
#
wget "https://www.openssl.org/source/openssl-1.0.1j.tar.gz"

# 下载最新版 zlib
# zlib 官网:
# http://www.zlib.net/
#
wget "http://zlib.net/zlib-1.2.8.tar.gz"

# 下载Google反代模块扩展
#
git clone https://github.com/cuber/ngx_http_google_filter_module

# 下载 substitutions 扩展
#
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module

# 解压缩
#

tar xzvf pcre-8.38.tar.gz
tar xzvf openssl-1.0.1j.tar.gz
tar xzvf zlib-1.2.8.tar.gz

# 进入LNMP目录,以LNMP1.3为例
#
cd lnmp1.3-full
修改lnmp.conf文件,添加nginx扩展编译参数

Nginx_Modules_Options='--with-pcre=/root/pcre-8.38 --with-openssl=/root/openssl-1.0.1j --with-zlib=/root/zlib-1.2.8 --add-module=/root/ngx_http_google_filter_module --add-module=/root/ngx_http_substitutions_filter_module'

保存退出

#用升级脚本升级nginx,./upgrade.sh nginx,输入nginx版本,比如1.8.1,然后开始升级

#
# 升级nginx完毕后我们查看nginx扩展nginx -V,如果以上几个扩展全都加上去了就对了。

LNMP安装google反代扩展

#最后,就是新建个虚拟主机,然后修改该域名的conf文件,vim /usr/local/nginx/conf/vhost/cmsky.com.conf

http配置方式

server {
server_name <你的域名>;
listen 80;

resolver 8.8.8.8;
location / {
google on;
}
}

https配置方式

server {
server_name <你的域名>;
listen 443;

ssl on;
ssl_certificate <你的证书>;
ssl_certificate_key <你的私钥>;

resolver 8.8.8.8;
location / {
google on;
}
}

推荐使用https方式,如果不用ssl证书域名容易被照顾。以上例举的仅是最简单配置,更多配置可以参考项目github介绍。

演示地址:https://g1.wen.lu/

weinxin
我的微信公众号
我的微信公众号扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:5   其中:访客  0   博主  0

    • Clarke Clarke 2

      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

      咦,为什么我弄好了访问是403,重启之后连访问都访问不了了。

        • 厘米 厘米 9

          Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

          @Clarke 上面的扩展都全了嘛,我测试是能反 代的~

            • Clarke Clarke 2

              Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

              @厘米 [private]
              nginx version: nginx/1.10.0
              built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
              built with OpenSSL 1.0.1j 15 Oct 2014
              TLS SNI support enabled
              configure arguments: –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_v2_module –with-http_gzip_static_module –with-ipv6 –with-http_sub_module –with-pcre=/root/pcre-8.38 –with-openssl=/root/openssl-1.0.1j –with-zlib=/root/zlib-1.2.8 –add-module=/root/ngx_http_google_filter_module –add-module=/root/ngx_http_substitutions_filter_module
              能帮我看看这是全了吗?
              [/private]

              • Clarke Clarke 2

                Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                @厘米 请问最后修改conf文件时,可不可以把原来的内容清除再粘贴你的配置内容?

                  • 厘米 厘米 9

                    Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                    @Clarke 扩展好像没少,你可以试试清空配置重贴看看!编辑完了记得nginx reload一下