欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Nginx+ModSecurity安全模塊部署的實(shí)現(xiàn)

 更新時(shí)間:2021年08月13日 09:38:39   作者:逝月流  
本文主要介紹了Nginx+ModSecurity安全模塊部署的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

為演示已安裝Nginx而未添加ModSecurity的情況,以下操作為先安裝Nginx,后添加ModSecurity模塊。

ModSecurity是一個(gè)開源的跨平臺(tái)Web應(yīng)用程序防火墻(WAF)引擎,,完美兼容nginx,是nginx官方推薦的WAF,并且支持支持OWASP規(guī)則。

中文網(wǎng)站:http://www.modsecurity.cn

應(yīng)用實(shí)戰(zhàn)可參考:http://www.modsecurity.cn/practice/

一、下載

1.Nginx下載

wget http://nginx.org/download/nginx-1.14.2.tar.gz

2.ModSecurity下載

wget http://www.modsecurity.cn/download/modsecurity/modsecurity-v3.0.4.tar.gz

二、部署

1.Nginx部署

1.1安裝依賴

yum  install  -y pcre* openssl* gcc c++ make

1.2 編譯安裝
解壓文件

tar  -xvf nginx-1.14.2.tar.gz 
cd nginx-1.14.2/

配置模塊

./configure  --prefix=/usr/local/nginx  --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log  --http-log-path=/var/log/nginx/access.log  --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock  --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre

執(zhí)行編譯

make
make install

創(chuàng)建賬號(hào)和目錄

useradd nginx -s /sbin/nologin
mkdir /var/tmp/nginx/

2.ModSecurity部署

2.1 安裝依賴

yum install -y gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel doxygen zlib-devel pcre-devel lmdb-devel libxml2-devel ssdeep-devel lua-devel libtool autoconf automake

2.2 編譯安裝
解壓文件

tar -xvf modsecurity-v3.0.4.tar.gz
cd modsecurity-v3.0.4/

編譯安裝

./configure
make
make install
cp modsecurity.conf-recommended /usr/local/modsecurity/modsecurity.conf
cp unicode.mapping /usr/local/modsecurity/

3.添加ModSecurity模塊

3.1查看Nginx編譯參數(shù)

/usr/local/nginx/sbin/nginx -V

3.2下載ModSecurity模塊

git clone https://github.com/SpiderLabs/ModSecurity-nginx.git

或至下載
https://github.com/SpiderLabs/ModSecurity-nginx 

3.3重新編譯Nginx

解壓模塊

unzip ModSecurity-nginx-master.zip 
#僅在下載安裝包情況下,如果是git clone 則不需要

編譯安裝

./configure  --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --add-module=../ModSecurity-nginx

 
#此處需要注意/ModSecurity-nginx路徑
make
make install

/usr/local/nginx/sbin/nginx -V #查看已經(jīng)有了ModSecurity模塊

添加配置文件

mkdir /usr/local/nginx/conf/modsecurity
cp /usr/local/modsecurity/modsecurity.conf  /usr/local/nginx/conf/modsecurity/
cp /usr/local/modsecurity/unicode.mapping  /usr/local/nginx/conf/modsecurity/

4.配置Nginx虛擬主機(jī)

4.1虛擬主機(jī)配置

vim /usr/local/nginx/conf/nginx.conf
    modsecurity on;
    modsecurity_rules_file /usr/local/nginx/conf/modsecurity/modsecurity.conf;
    
 #在http節(jié)點(diǎn)添加表示全局配置,在server節(jié)點(diǎn)添加表示為指定網(wǎng)站配置

4.2Modsecurity配置

vim /usr/local/nginx/conf/modsecurity/modsecurity.conf
#更改一下部分
SecRuleEngine On
SecAuditLogParts ABCDEFHZ

#追加到配置文件
Include /usr/local/nginx/conf/modsecurity/crs-setup.conf
Include /usr/local/nginx/conf/modsecurity/rules/*.conf

4.3下載規(guī)則文件

wget http://www.modsecurity.cn/download/corerule/owasp-modsecurity-crs-3.3-dev.zip
#Modsecurity中文網(wǎng)下載
wget https://github.com/coreruleset/coreruleset
#github下載

4.4 配置規(guī)則

unzip owasp-modsecurity-crs-3.3-dev.zip 
cd owasp-modsecurity-crs-3.3-dev/

cp crs-setup.conf.example /usr/local/nginx/conf/modsecurity/crs-setup.conf
cp -r rules /usr/local/nginx/conf/modsecurity/

cd /usr/local/nginx/conf/modsecurity/rules
mv REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
mv RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf

4.5測(cè)試

#瀏覽器 或 curl訪問測(cè)試,返回403
curl -I 'http://localhost/?id=1 AND 1=1' 

到此這篇關(guān)于Nginx+ModSecurity安全模塊部署的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Nginx ModSecurity部署內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • nginx配置proxy_pass后返回404問題以及Nginx host相關(guān)變量的說(shuō)明

    nginx配置proxy_pass后返回404問題以及Nginx host相關(guān)變量的說(shuō)明

    這篇文章主要介紹了nginx配置proxy_pass后返回404問題以及Nginx host相關(guān)變量的說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Nginx訪問靜態(tài)資源配置的實(shí)現(xiàn)步驟

    Nginx訪問靜態(tài)資源配置的實(shí)現(xiàn)步驟

    Nginx 擅長(zhǎng)于底層服務(wù)器端資源的處理,例如靜態(tài)資源處理轉(zhuǎn)發(fā)、反向代理,負(fù)載均衡等,本文主要介紹了Nginx訪問靜態(tài)資源配置的實(shí)現(xiàn)步驟,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-09-09
  • 關(guān)于nginx+uWsgi配置遇到的問題的解決

    關(guān)于nginx+uWsgi配置遇到的問題的解決

    uWSGI 是在像 nginx 、 lighttpd 以及 cherokee 服務(wù)器上的一個(gè)部署的選擇,本篇文章主要介紹了關(guān)于nginx+uWsgi配置遇到的問題的解決,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • nginx多https證書配置實(shí)現(xiàn)

    nginx多https證書配置實(shí)現(xiàn)

    本文主要介紹了nginx多https證書配置實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-04-04
  • FastDFS+Nginx如何搭建本地服務(wù)器并實(shí)現(xiàn)遠(yuǎn)程訪問

    FastDFS+Nginx如何搭建本地服務(wù)器并實(shí)現(xiàn)遠(yuǎn)程訪問

    FastDFS是一個(gè)開源的輕量級(jí)分布式文件系統(tǒng),它對(duì)文件進(jìn)行管理,功能包括:文件存儲(chǔ)、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲(chǔ)和負(fù)載均衡的問題,這篇文章主要介紹了FastDFS+Nginx搭建本地服務(wù)器并實(shí)現(xiàn)遠(yuǎn)程訪問,需要的朋友可以參考下
    2023-11-11
  • nginx開啟HSTS讓瀏覽器強(qiáng)制跳轉(zhuǎn)HTTPS訪問詳解

    nginx開啟HSTS讓瀏覽器強(qiáng)制跳轉(zhuǎn)HTTPS訪問詳解

    這篇文章主要介紹了nginx開啟HSTS讓瀏覽器強(qiáng)制跳轉(zhuǎn)HTTPS訪問詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-05-05
  • 詳解nginx日志定時(shí)備份和刪除

    詳解nginx日志定時(shí)備份和刪除

    本篇文章主要介紹了nginx日志定時(shí)備份和刪除 ,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-06-06
  • 詳解Nginx服務(wù)器中配置Sysguard模塊預(yù)防高負(fù)載的方案

    詳解Nginx服務(wù)器中配置Sysguard模塊預(yù)防高負(fù)載的方案

    這篇文章主要介紹了詳解Nginx服務(wù)器中配置Sysguard模塊預(yù)防高負(fù)載的方案,該模塊由阿里巴巴的團(tuán)隊(duì)開發(fā),能夠設(shè)置負(fù)載閥值,比較強(qiáng)大,需要的朋友可以參考下
    2016-01-01
  • 一文帶你搞懂什么是Nginx服務(wù)器

    一文帶你搞懂什么是Nginx服務(wù)器

    這篇文章主要介紹了一文帶你搞懂什么是Nginx,Nginx?(engine?x)?是一個(gè)高性能的HTTP和反向代理web服務(wù)器,同時(shí)也提供了iMAP/POP3/SMTP服務(wù),需要的朋友可以參考下
    2023-04-04
  • 通過(guò)Nginx定義Header頭信息的實(shí)現(xiàn)步驟

    通過(guò)Nginx定義Header頭信息的實(shí)現(xiàn)步驟

    本文主要介紹了通過(guò)Nginx定義Header頭信息的實(shí)現(xiàn)步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04

最新評(píng)論