2

今日、nginxにmod_securityをインストールしました。次のブロックを に追加しました/etc/nginx/nginx

server {
listen       80;
server_name  localhost;

location / {
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;
}

}

Nginx を再起動した後、次のエラーが発生しました。

nginx: [emerg] unknown directive "ModSecurityEnabled" in /etc/nginx/conf.d/nginx.conf:6
nginx: configuration file /etc/nginx/nginx.conf test failed

の出力nginx -V:

nginx version: nginx/1.4.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'

何がうまくいかないのですか?

4

2 に答える 2

6

公式ドキュメントによると:

nginx サーバーの拡張モデルには、動的にロードされるモジュールが含まれていないため、メイン サーバーのソース コードを使用して ModSecurity をコンパイルする必要があります。nginx は複数の Unix ベースのプラットフォーム (および Windows) で利用できるため、現時点で nginx の ModSecurity を取得する推奨される方法は、指定された環境でコンパイルすることです。

ソース: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#Installation_for_NGINX

nginx.conf にいくつかの行を追加して機能させることはできません。

より効率的に支援を受けたい場合は、次のことも検討してください。それまでの間、スタック オーバーフローをより良い場所にするために参加してください。

  • 助けを求める前にドキュメントを読んでください (仕組みを理解するのに 3 分かかりました)。
  • 問題のより明確なタイトルを選択してください。
  • コンテンツを読みやすくするために、コンテンツを自動修正してみてください。

幸運を!

于 2014-07-15T15:35:37.387 に答える
0

私はNGinx plusでこれを行ったので、完全に同一かどうかはわかりませんが、そう思われます...

Yum install nginx-modsecurity (nginx とその nginx-plus-module-modsecurity 用) /etc/nginx/nginx.confload_module modules/ngx_http_modsecurity_module.so;のトップ レベルに追加 - サーバー ブロックの外側

次に、サーバーブロック内で modsecurity on; modsecurity_rules_file /some/path/to/rules/modsecurity-recommended.conf

modsecurirty-recommended の推奨コンテンツは、次の場所から取得できます。https://docs.nginx.com/nginx-waf/admin-guide/nginx-plus-modsecurity-waf-owasp-crs/

これは現時点で私のために働いています、それが役立つことを願っています

于 2018-11-07T14:35:11.970 に答える