logo

  • 欢迎各位友链


  • 首页
  • 关于
  • 技术文章
  • 资源分享
  • 微语
  • 相册
  • 优秀博客
  • 留言

宝塔面板安装云锁Nginx自编译web防护教程

 2019/12/06
 Garlic
 0
 751
“ 宝塔安装请采用编译安装Nginx!本教程不适用于非宝塔用户以及Apache用户,配置编译环境 ”
宝塔面板安装云锁Nginx自编译web防护教程

宝塔安装请采用编译安装 Nginx!

本教程不适用于非宝塔用户以及 Apache 用户

配置编译环境

yum install -y gcc gcc-c++ pcre-devel openssl openssl-devel

查看 Nginx 位置

ps -elf | grep nginx

备份 宝塔 Nginx

cd /www/server/nginx/sbin/

cp nginx nginx.bak

下载云锁防护模块压缩包

wget //codeload.github.com/yunsuo-open/nginx-plugin/zip/master -O nginx-plugin-master.zip

unzip nginx-plugin-master.zip

cd nginx-plugin-master/

pwd

查看宝塔编译好的 Nginx 加载模块,在重新编译加载云锁防护模块的时候仍需加载这些模块

nginx -V

注意这个命令是大写的V,如果小写 v 是不会显示模块的

将 ./configure arguents:之后的内容复制到记事本备用,比如我的是:

--user=www --group=www --prefix=/www/server/nginx --with-openssl=/www/server/nginx/src/openssl --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-http_concat_module --with-ld-opt=-Wl,-E --with-jemalloc --without-http_upstream_session_sticky_module --with-pcre=pcre-8.40

(我的仅供参考,实际以自己的为准)

编译内容

cd /www/server/nginx/src

./configure 上一步记事本中的备用内容 加上 --add-module=/root/nginx-plugin-master

./configure 和记事本复制的内容之间有个空格,后面的 --add-module 前面也有个空格,比如我的编译命令为:

./configure --user=www --group=www --prefix=/www/server/nginx --with-openssl=/www/server/nginx/src/openssl --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-http_concat_module --with-ld-opt=-Wl,-E --with-jemalloc --without-http_upstream_session_sticky_module --with-pcre=pcre-8.40 --add-module=/root/nginx-plugin-master

(我的仅供参考,实际以自己的为准)

./configure 上一步的内容 --add-module=/root/nginx-plugin-master

编译完成后将 ngx_modules.c 中的 &ngx_http_yunsuo_module, 向下移动到 ngx_http_userid_filter_module 和 ngx_http_headers_filter_module 之间。(已在此之间的则可忽略)

Nginx1.8.0 以上和 Tengine 2.2.0 则需要修改 objs/Makefile 文件和 objs/ngx_modules.c 来支持 POST 过滤和内容过滤

首先,在 Makefile 文件中的 CFLAGS=...-Werror -g 后追加宏定义 -DHIGHERTHAN8

vi objs/Makefile
CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -DHIGHERTHAN8

然后将 ngx_modules.c 中的 &ngx_http_yunsuo_module ,向下移动

vi objs/ngx_modules.c
ngx_module_t *ngx_modules[] = {
   &ngx_core_module,
   ......
   &ngx_http_upstream_keepalive_module,
   &ngx_http_upstream_zone_module,
-----------下面这行向下移动----------------
   `&ngx_http_yunsuo_module`,
------------------------------------------
   &ngx_http_stub_status_module,
   ......
   &ngx_http_userid_filter_module,
---------------移动到该位置-----------------
   &ngx_http_yunsuo_module,
-------------------------------------------
   &ngx_http_headers_filter_module,
   &ngx_http_copy_filter_module,
   &ngx_http_range_body_filter_module,
   &ngx_http_not_modified_filter_module,
   NULL
};

char *ngx_module_names[] = {   "objs/ngx_modules.c" 186L, 6441C
   ......
};

修改后进行 make(如原本无 Nginx,make 后还需 make install)

make

make 完成后将系统中原有的 Nginx 用重新编译生成的 Nginx 文件替换,替换后重启 Nginx 使新编译 Nginx 生效

复制新编译的 Nginx

rm -rf /www/server/nginx/sbin/nginx

cp /www/server/nginx/src/objs/nginx /www/server/nginx/sbin/

service nginx restart

重启 Nginx

service nginx restart

输入你的网址后面加上 /?order%20by,测试云锁


支付宝 微信
 56

Linux
  • 本文链接: 宝塔面板安装云锁Nginx自编译web防护教程 | Garlic`s Blog
  • 版权声明:若无特殊注明,本文皆为《Garlic`s Blog》原创,转载请保留文章出处。
  • 备注:相关侵权、举报、投诉及建议等,请发E-mail:php_garlic@163.com。
 如何屏蔽php错误,php错误级别常量
 Laravel 使用 Captcha 登录验证码
  • 日常开发的效率提升工具
    日常开发的效率提升工具
  • 宝塔7.6.0去除登陆限制,及强制跳转 /bind解决方法
    宝塔7.6.0去除登陆限制,及强制跳转 /bind解决方法
  • Laravel 常用扩展包
    Laravel 常用扩展包
  • Laravel route() 方法生成 HTTPS 链接
    Laravel route() 方法生成 HTTPS 链接
暂无评论,快抢沙发吧~
  • 😋 支持Emoji表情,可用的 Emoji 请见 🤘 👉 Emoji 列表 ⭐ ✨
 请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!



 验证码
Garlic
Garlic
你能够拥有梦想,而且梦想能够实现,网络是离你梦想最近的地方!
 269
 关注 公众号
1151 本站已勉强运行
PV 今日pv
27 文章数量
文章搜索
最新评论
  • nevermore
    nevermore 2020/12/16
    文章

    博主这个网站搭建花了多久的哈。扒代码花了多久的哈

  • 演员
    演员 2020/10/03
    文章

    老哥这板子好帅,能分享哈不

 点击排行
 最多点赞
  • 宝塔面板安装云锁Nginx自编译web防护教程
    宝塔面板安装云锁Nginx自编译web防护教程
    2019/12/06浏览:751
  • Laravel Eloquent: 使用 hasMany 来处理『无限极分类』
    Laravel Eloquent: 使用 hasMany 来处理『无限极分类』
    2020/01/24浏览:725
  • PHP常用的字符串函数
    PHP常用的字符串函数
    2020/01/26浏览:627
  • Laravel Eloquent: 使用 hasMany 来处理『无限极分类』
    Laravel Eloquent: 使用 hasMany 来处理『无限极分类』
    2020/01/24点赞:100
  • 清除Windows 垃圾
    清除Windows 垃圾
    2020/09/30点赞:87
  • 日常开发的效率提升工具
    日常开发的效率提升工具
    2021/10/19点赞:81
 标签
常用工具 Windows 宝塔 Office SoftEther 负载均衡 百度网盘 Yii Thinkphp Apache
 友情链接
Laravel China 社区 椰子皮博客 站点导航
首页 Emoji 表情列表 网站地图
CopyRight © 2019 - 2023 - Garlic`s Blog - 粤ICP备17064364号-1
声明: 本站资源来源自网络,如有侵权,请联系站长删除! 本站前端模板采用 椰子皮博客