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 リンク アドレスの後に疑問符 (?) を追加すると、どのような意味になりますか?
ハイパーリンク a タグはリンク ポイントを表し、英語の単語「anchor」の略語です。その機能は、...
Linuxバージョンのアップグレード: 1. まず、Linuxオペレーティングシステムに付属するPy...
目次1. 使いやすい2. 関数内でジェネリックを使用する3. クラス内でジェネリックを使用する4. ...
一般的なアプリケーションシナリオ現在のアプリのインターフェースは基本的に同じであり、グリッドレイアウ...
1. はじめに今、ウォーターフォールフローについて書くことは、古い内容の焼き直しと見なされますか?気...
導入通常、バックグラウンド サーバー プログラムには 1 つのプロセスのみが必要ですが、単一のプロセ...
シナリオ最近の要件は、モバイル デバイス用の h5 ページです。これには、選択可能なカードの行が必要...
Node-red をデータベース (mysql) に接続するには、まずコンピューターに MySQL ...
目次Webコンポーネントカスタム要素概要HTMLTemplateElement コンテンツ テンプレ...
目次ミキシンMixin ノート (重複名)ローカルミックスイングローバル ミックスイン定義とグローバ...
mysqlのリモートアクセス権を有効にするデフォルトでは、MySQL ユーザーにはリモート アクセ...
以下のように表示されます。 XML/HTML コードコンテンツをクリップボードにコピー<htm...
1.リスナーを見る時計のご紹介 'vue' から { ref, reactive, ...
1. ツールディレクトリのファイル構造 [root@www tools]# ツリーツール/ ツール/...
目次DockerファイルドキュメントJenkins の設定Spring Boot プロジェクトでは、...