openresty用naxsi防xss、SQL注入


下載naxsi

wget https://github.com/nbs-system/naxsi/archive/untagged-afabfc163946baa8036f.tar.gz
tar zxvf untagged-afabfc163946baa8036f.tar.gz
mv naxsi-untagged-afabfc163946baa8036f/ naxsi

編譯openresty加上--add-module

./configure --prefix=/usr/local/openresty --with-http_stub_status_module --with-http_gzip_static_module --with-luajit --add-module=/usr/local/naxsi/naxsi_src

將核心規則復制到openresty的conf中

cp /usr/local/naxsi/naxsi_config/naxsi_core.rules /usr/local/openresty/nginx/conf/

自定義一個規則文件

vi /usr/local/openresty/nginx/conf/mySite.rules

內容為

#開啟 naxsi
SecRulesEnabled;
#定義阻止請求的位置
DeniedUrl "/50x.html";
#CheckRules, 確定 naxsi 何時采取行動
CheckRule "$SQL >= 8" BLOCK;
CheckRule "$RFI >= 8" BLOCK;
CheckRule "$TRAVERSAL >= 4" BLOCK;
CheckRule "$EVADE >= 4" BLOCK;
CheckRule "$XSS >= 8" BLOCK;

編輯opernresty的主配置文件

vi /usr/local/openresty/nginx/conf/nginx.conf

在http中引用核心規則

在接口中引用自定義規則

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM