banner
moeyy

moeyy

一条有远大理想的咸鱼。
github
mastodon
email

宝塔+云锁nginx自編譯web防護教程

本教程是博主親測之後才寫出來的,分享給不會編譯云锁 nginx 自編譯模塊的用戶。

首先在操作前,請確認已經配置好宝塔面板,並採用編譯方法配置的 nginx 環境!(不是極速安裝,是編譯安裝)

並妥善備份 Nginx 文件,以及確定本教程不適用於非宝塔用戶以及 apache 用戶

其次,本教程只要按照一步一步來,傻瓜都能編譯好。官方教程小白看一眼懵逼了,本教程沒那麼複雜。

配置編譯環境,宝塔如果編譯好 nginx 是默認配置好環境的,可以忽略這個配置環境...

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

你可以使用 SSH 工具以 ROOT 權限登陸之後下載備份 nginx,也可以直接使用命令備份 nginx

查看 nginx 位置

ps -elf  grep nginx

進入宝塔 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 --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

(我的僅供參考,實際以自己的為準)

進入 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 --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

(我的僅供參考,實際以自己的為準)

等待命令結束,輸入編譯命令

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,測試云锁

image

開啟驗證碼防 CC

image

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。