宝塔Nginx安装ngx_waf LTS 版
为什么选择 ngx_waf
基础防护:如 IP 或 IP 网段的黑白名单、URI 黑白名单和请求体黑名单等。
使用简单:配置文件和规则文件书写简单,可读性强。
高性能:使用高效的 IP 检查算法和缓存机制。
高级防护:兼容 ModSecurity (opens new window),因此你可以使用开放式网络应用安全项目(OWASP)® 的核心规则库 (opens new window)。
友好爬虫验证:支持验证 Google、Bing、Baidu 和 Yandex 的爬虫并自动放行,避免错误拦截。
验证码:支持三种验证码:hCaptcha、reCAPTCHAv2 和 reCAPTCHAv3。
#功能
兼容 ModSecurity (opens new window)。此功能仅限最新的 Current 版本。
SQL 注入防护(Powered By libinjection (opens new window))。
XSS 攻击防护(Powered By libinjection (opens new window))。
支持 IPV4 和 IPV6。
支持开启验证码(CAPTCHA),支持 hCaptcha (opens new window)、reCAPTCHAv2 (opens new window)和 reCAPTCHAv3 (opens new window)。
支持识别友好爬虫(如 BaiduSpider)并自动放行(基于 User-Agent 和 IP 的识别)。此功能仅限最新的 Current 版本。
CC 防御,超出限制后自动拉黑对应 IP 一段时间或者使用验证码做人机识别。
IP 黑白名单,同时支持类似
192.168.0.0/16
和fe80::/10
,即支持点分十进制和冒号十六进制表示法和网段划分。POST 黑名单。
URL 黑白名单
查询字符串(Query String)黑名单。
UserAgent 黑名单。
Cookie 黑名单。
Referer 黑白名单。
官方网站:https://github.com/ADD-SP/ngx_waf
安装比较复杂,研究了一上午终于装好了,Current 版功能比较多,但是可能不稳定,生产环境下还是装LTS 版好了。直接在nginx已装好的情况下,重新编译替换,跟官方的安装说明有点不一样,可能有错误,不过能用 ^-^
yum -y update yum -y install libtool yum -y install https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/23/x86_64/b/bison-3.0.4-3.fc23.x86_64.rpm yum install gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel doxygen zlib-devel pcre-devel git libcurl libcurl-devel cd /usr/local/src git clone https://github.com/jedisct1/libsodium.git --branch stable cd libsodium ./configure --prefix=/usr/local/libsodium --with-pic make -j$(nproc) make install cd /usr/local/src wget https://github.com/maxmind/libmaxminddb/releases/download/1.6.0/libmaxminddb-1.6.0.tar.gz -O libmaxminddb.tar.gz mkdir libmaxminddb tar -zxf "libmaxminddb.tar.gz" -C libmaxminddb --strip-components=1 cd libmaxminddb ./configure --prefix=/usr/local/libmaxminddb make -j$(nproc) make install cd /www/server/nginx/src git clone -b lts https://github.com/ADD-SP/ngx_waf.git rm -rf /usr/local/src/ngx_waf cp -r ngx_waf /usr/local/src/ngx_waf cd ngx_waf make git clone https://github.com/libinjection/libinjection.git inc/libinjection cd /www/server/nginx/src git clone https://github.com/troydhanson/uthash.git inc/uthash export LIB_UTHASH=/www/server/nginx/src/uthash export LIB_SODIUM=/usr/local/libsodium cd /usr/local/src git clone https://hub.fastgit.xyz/troydhanson/uthash.git export LIB_UTHASH=/usr/local/src/uthash cd /www/server/nginx/src ./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-stream_ssl_preread_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 --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module --add-module=/www/server/nginx/src/ngx_waf --with-cc-opt='-std=gnu99 -Wno-sign-compare -Wno-error' make service nginx stop rm -rf /www/server/nginx/sbin/nginx cp /www/server/nginx/src/objs/nginx /www/server/nginx/sbin/ service nginx start nginx -V
暂无评论
发表评论