nginx安装ngx_waf模块 安装部署


https://hub.docker.com/r/addsp/ngx_waf-prebuild

https://github.com/ADD-SP/ngx_waf


-ngx_waf模块说明 - nginx、

https://abc.htmltoo.com/thread-46504.htm


-长期维护版(LTS)

cd  /data/site/htmltoo.f/htmltoo.soft/src/common/nginx-module/ngx_waf/lts

git clone -b master https://github.com/ADD-SP/ngx_waf.git

-最新版(Current)

cd  /data/site/htmltoo.f/htmltoo.soft/src/common/nginx-module/ngx_waf/current

git clone -b current https://github.com/ADD-SP/ngx_waf.git


sh assets/guide.sh

# It is recommended that you use dynamic modules.

# 如果输出上面这行则建议使用动态模块。

# It is recommended that you use static modules.

# 如果输出上面这行则建议使用静态模块。


docker run --rm -d -v  /data/file:/out addsp/ngx_waf-prebuild:ngx-1.22.1-module-current-glibc cp /modules/ngx_http_waf_module.so  /out

docker run --rm -d -v  /data/file:/out addsp/ngx_waf-prebuild:ngx-1.25.4-module-current-glibc cp /modules/ngx_http_waf_module.so  /out


-使用动态模块

cd  /data/site/htmltoo.f/htmltoo.soft/src/common/nginx-module/ngx_waf  

-用于nginx-1.24.0的current版的模块,当前目录下生成

sh  assets/download.sh 1.24.0 current

cp  ngx_http_waf_module.so  /etc/nginx/modules


vim  /data/docker/nginx/nginx/nginx.conf

load_module "/etc/nginx/modules/ngx_http_waf_module.so";
...
#waf
include /etc/nginx/conf.d/waf.ini;
...

vim  /data/docker/nginx/nginx/conf.d/waf.ini

# on 表示启用,off 表示关闭。
  waf on;
# 规则文件所在目录的绝对路径,必须以 / 结尾。
  waf_rule_path /data/site/htmltoo.f/htmltoo.soft/src/common/nginx-module/ngx_waf/assets/rules/;
# 防火墙工作模式,STD 表示标准模式。
  waf_mode STD;
# CC 防御参数,1000 每分钟请求次数上限,超出上限后封禁对应 ip 60 分钟。
  waf_cc_deny rate=1000r/m duration=60m;
# 最多缓存 50 个检测目标的检测结果,对除了 IP 黑白名单检测、CC 防护和 POST 检测以外的所有检测生效。
  waf_cache capacity=50;
# 被攻击时降低带宽占用
  waf_http_status cc_deny=444;


nginx  -s  reload


cd /data/site/htmltoo.f/htmltoo.soft/src/common/nginx-module/nginx-1.22.1


apt update

apt install -y libsodium23   libsodium-dev   libcurl4-openssl-dev    git   libmodsecurity-dev  libmodsecurity3

cat >> /etc/profile <<END

export LIB_UTHASH=/usr/local/src/uthash 

# 如果操作系统的 Ubuntu 则不用写下面这两行

export LIB_SODIUM=/usr/local/src/libsodium

export LIB_MODSECURITY=/usr/local/src/modsecurity

END

source /etc/profile


git clone https://github.com/libinjection/libinjection.git   lib/libinjection

git clone https://github.com/DaveGamble/cJSON.git   lib/cjson

git clone https://github.com/libinjection/libinjection.git   inc/libinjection


-长期维护版(LTS)

git clone -b master https://github.com/ADD-SP/ngx_waf.git

-最新版(Current)

-git clone -b current https://github.com/ADD-SP/ngx_waf.git

cd  ngx_waf  &&  make && apt-get install --yes flex  bison

cd /usr/local/src  

git clone https://github.com/troydhanson/uthash.git 

export LIB_UTHASH=/usr/local/src/uthash 

git clone https://github.com/jedisct1/libsodium.git --branch stable libsodium-src 

cd libsodium-src  && ./configure --prefix=/usr/local/src/libsodium --with-pic 

export LIB_SODIUM=/usr/local/src/libsodium  && make -j$(nproc) && make check -j $(nproc) && make install

cd  /data/site/htmltoo.f/htmltoo.soft/src/common/nginx-module/ngx_waf  

git clone https://github.com/libinjection/libinjection.git   lib/libinjection

git clone https://github.com/DaveGamble/cJSON.git   lib/cjson

git clone https://github.com/troydhanson/uthash.git  lib/uthash


docker cp /data/site/docker/env/nginx/nginx/modules/1.22.1/ngx_http_waf_module.so nginx:/etc/nginx/modules

docker cp /data/site/docker/env/nginx/nginx/modules/1.25.4/ngx_http_waf_module.so nginx:/etc/nginx/modules



签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回