admin 发表于 2025-2-16 12:57:32

宝塔Nginx自编译云锁web防护教程-可以防御CC攻击

宝塔Nginx自编译云锁web防护教程-可以防御CC攻击
首先在操作前,请确认已经配置好宝塔面板,并采用编译方法配置的nginx环境!(不是极速安装,是编译安装,否则Nginx目录里木有src目录,不能进行自编译)
并妥善备份Nginx文件,以及确定本教程不适用于非宝塔用户以及apache用户

其次,本教程只要按照一步一步来,傻瓜都能编译好。官方教程小白看一眼懵逼了,本教程没那么复杂。
配置编译环境,宝塔如果编译好nginx是默认配置好环境的,可以忽略这个配置环境...
yum install -y gcc gcc-c++ pcre-devel openssl openssl-devel
你可以使用SSH工具以ROOT权限登陆之后下载备份nginx,也可以直接使用命令备份nginx
进入宝塔nginx目录cd /www/server/nginx/sbin/
进入宝塔nginx目录

[*]cd /www/server/nginx/sbin/
[*]备份宝塔nginx

[*]cp nginx nginx.bak
进入root目录



cd /root

下载云锁防护模块压缩包


wget https://codeload.github.com/yunsuo-open/nginx-plugin/zip/master -O nginx-plugin-master.zip
解压云锁防护模块压缩包

[*]unzip nginx-plugin-master.zip
查看宝塔编译好的nginx加载模块,在重新编译加载云锁防护模块的时候仍需加载这些模块



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

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


--user=www --group=www --prefix=/www/server/nginx --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-openssl=/www/server/nginx/src/openssl --with-pcre=pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_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-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc


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

进入nginx源码目录,对nginx进行重新编译,操作之前请确认自己的nginx是编译模式安装的,而不是宝塔面板的极速安装
cd /www/server/nginx/src
编译内容
./configure 上一步记事本中的备用内容 --add-module=/root/nginx-plugin-master

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


./configure --user=www --group=www --prefix=/www/server/nginx --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-openssl=/www/server/nginx/src/openssl --with-pcre=pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_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-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --add-module=/root/nginx-plugin-master


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

等待命令结束,输入编译命令
make
完成后将系统中原有的nginx用重新编译生成的nginx文件替换

停止nginx
service nginx stop

删除原来的nginx,操作之前请确认自己的nginx已经备份
rm -rf /www/server/nginx/sbin/nginx

复制新编译的nginx



[*]cp /www/server/nginx/src/objs/nginx /www/server/nginx/sbin/
启动nginx




[*]service nginx start
通过PC端登陆云锁,PC端刷新后可以看到已识别nginx插件(由灰色变为绿色)

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




















XMNGZS 发表于 2025-2-18 23:23:45

感谢楼主分享。

墨香逸逸影 发表于 2025-2-26 14:26:29

帮你顶下哈!!

逸兴遄飞 发表于 2025-2-26 14:43:31

找到好贴不容易,我顶你了,谢了

妙墨逸清辉 发表于 2025-2-26 14:54:59

有竞争才有进步嘛

逸墨逸逸香 发表于 2025-2-26 15:08:21

真是 收益 匪浅

暮雨朝云 发表于 2025-2-26 15:09:00

小手一抖,钱钱到手!

诗韵逸逸声 发表于 2025-2-26 15:13:08

沙发!沙发!

诗韵寄天涯 发表于 2025-2-26 15:56:40

路过,学习下

棋道高深 发表于 2025-2-26 16:40:57

真是 收益 匪浅
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: 宝塔Nginx自编译云锁web防护教程-可以防御CC攻击