Nginx はインストールされているが ModSecurity が追加されていない状況を示すために、次の操作では、最初に Nginx をインストールし、次に ModSecurity モジュールを追加します。 ModSecurity は、nginx と完全に互換性のあるオープンソースのクロスプラットフォーム Web アプリケーション ファイアウォール (WAF) エンジンです。nginx によって公式に推奨されている WAF であり、OWASP ルールをサポートしています。 中国語ウェブサイト: http://www.modsecurity.cn 実際の適用については、http://www.modsecurity.cn/practice/ を参照してください。 1. ダウンロード1. Nginxをダウンロードする http://nginx.org/download/nginx-1.14.2.tar.gz をダウンロードしてください 2. ModSecurityのダウンロード http://www.modsecurity.cn/download/modsecurity/modsecurity-v3.0.4.tar.gz をダウンロードしてください 2. 展開1.Nginxのデプロイメント1.1 インストールの依存関係 yum インストール -y pcre* openssl* gcc c++ make 1.2 解凍したファイルをコンパイルしてインストールする tar -xvf nginx-1.14.2.tar.gz nginx-1.14.2をインストールします 構成モジュール ./CONFIGURE ---PREFIX =/usr/local/nginx - sbin-path =/usr/local/nginx/sbin/nginx - conf-path =/usr/nginx/conf/nginx.conf -error-log-path =/var/log/nginx/error.log-http-log-path = bar/var/var/var /nginx/nginx.pid - lock-path =/var/lock/nginx.lock.lock - user = nginx - group = nginx -with-http_ssl_module -with-http_stub_status_module -with-http_gzip_static_module -htp-hptpats/tmp-bodule-bodule-bodule-bodule-body-body ttp-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-p-ppat -PCREで コンパイルの実行 作る インストールする アカウントとディレクトリを作成する ユーザー追加 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 作る インストールする cp modsecurity.conf-推奨 /usr/local/modsecurity/modsecurity.conf cp unicode.mapping /usr/local/modsecurity/ 3. ModSecurityモジュールを追加する3.1 Nginx コンパイルパラメータを表示する nginx の sbin ディレクトリに nginx の sbin ディレクトリを作成します。 3.2 ModSecurityモジュールをダウンロードする git クローン https://github.com/SpiderLabs/ModSecurity-nginx.git または、https://github.com/SpiderLabs/ModSecurity-nginx からダウンロードしてください。 3.3 Nginxを再コンパイルする 減圧モジュール ModSecurity-nginx-master.zip を解凍します。 #インストールパッケージをダウンロードする場合のみ、git cloneの場合は不要 コンパイルしてインストールする ./CONFIGURE ---PREFIX =/usr/local/nginx - sbin-path =/usr/local/nginx/sbin/nginx - conf-path =/usr/nginx/conf/nginx.conf -error-log-path =/var/log/nginx/error.log-http-log-path = bar/var/var/var /nginx/nginx.pid - lock-path =/var/lock/nginx.lock.lock - user = nginx - group = nginx -with-http_ssl_module -with-http_stub_status_module -with-http_gzip_static_module -htp-hptpats/tmp-bodule-bodule-bodule-bodule-body-body ttp-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-p-ppat -with-pcre -add-module = ../modsecurity-nginx #ここに注意/ModSecurity-nginx パスを作成 インストールする /usr/local/nginx/sbin/nginx -V #ModSecurityモジュールがすでに利用可能であることを確認します プロフィールを追加する /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仮想ホストを構成する4.1 仮想ホストの設定 vim /usr/local/nginx/conf/nginx.conf modsecurity オン; modsecurity_rules_file /usr/local/nginx/conf/modsecurity/modsecurity.conf; #httpノードに追加するとグローバル構成が示され、serverノードに追加すると特定のWebサイトの構成が示されます 4.2Modsecurityの設定 下記のコマンドを実行して、 /usr/local/nginx/conf/modsecurity/modsecurity.conf を編集します。 #次の部分を変更する SecRuleEngine On SecAuditLogParts ABCDEFHZ #設定ファイルに /usr/local/nginx/conf/modsecurity/crs-setup.conf を追加します /usr/local/nginx/conf/modsecurity/rules/*.conf を含める 4.3 ルールファイルのダウンロード http://www.modsecurity.cn/download/corerule/owasp-modsecurity-crs-3.3-dev.zip をダウンロードしてください #ModsecurityChinese ウェブサイトのダウンロード wget https://github.com/coreruleset/coreruleset #github ダウンロード 4.4 構成ルール 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 ルール /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 テスト #ブラウザまたはcurlアクセステスト、403を返す curl -I 'http://localhost/?id=1 AND 1=1' Nginx+ModSecurity セキュリティ モジュールの導入実装に関するこの記事はこれで終わりです。Nginx ModSecurity 導入に関するより詳しい内容については、123WORDPRESS.COM の過去の記事を検索するか、以下の関連記事を引き続きご覧ください。今後とも 123WORDPRESS.COM をよろしくお願いいたします。 以下もご興味があるかもしれません:
|
<<: Vue+ElementUI で超大規模なフォーム例を処理する方法
>>: CSS リンク アドレスの後に疑問符 (?) を追加すると、どのような意味になりますか?
目次 はじめに 同期 非同期とブロッキング JavaScript のノンブロッキング コールバック ...
アプリケーションや Web サイトのパフォーマンスが成功の重要な要素であることは誰もが知っています。...
目次1. 需要背景2. 最適化計画3. 具体的な実施3.1 フロントエンドコード3.2 背景コード4...
目次序文VMware クローン仮想マシン (準備、3 台の仮想マシンのクローン、1 台のマスター、2...
序文1. デバウンス: 高頻度イベントがトリガーされた後、関数は n 秒以内に 1 回だけ実行されま...
MySQL のデータはディスクに書き込む必要があることは誰もが知っています。ディスクの読み取りと書き...
訪問するたびにブラウザにCookieが生成されますが、 Cookieの存在はユーザーにとって良いこと...
レイアウトにul>liを使用した単一行レイアウトを以下に示します。 <ul class=...
1. BIOSを確認するまず、コンピュータの起動モードを確認します。win+R と入力し、msinf...
ソフトウェアのダウンロードソフトウェアのダウンロード リンク: https://pan.baidu....
influxDB の紹介influxDB は分散型時系列データベースです。 cAdvisor はリ...
この記事ではjQueryを使用して、階段のスライド効果を実装し、フロアをスクロールし、フロアボタンを...
Web 開発では、次のような文字によく遭遇します: これは実際には HTML が...
CSS カウンター属性はほぼすべてのブラウザ (IE8 を含む) でサポートされていますが、あまり使...
目次基本設定エントリファイル main.jsアプリ.vue表紙ヘッダー検索バー本体当プロジェクトでは...