최근 Apache를 대체하는 웹서버로 Nginx가 많이 사용되고 있습니다.
그러나, Nginx에서는 Apache에 비하여 다양한 3rd-Party 모듈들을 아직 지원하지 않아,
Apache에서 Nginx로의 전환을 고려 하다가도 포기하는 사례가 많이 있습니다.
대표적인 한가지가 Apache의 웹 방화벽 모듈로 주로 사용되는 Mod_Security가 아닐까 생각 됩니다
이러한 불편한 점을 극복하고 Nginx가 널리 활용 되길 바라는 마음에,
mod_security를 포함하여 빌드된 CentOS 6.x 64비트용 Nginx의 rpm을 배포 합니다.
그 밖에도, nginx-rtmp-module 과 nginx-module-vts 도 포함되어 있습니다.
아래 파일을 다운로드 하여, rpm -ivh nginx-1.9.4-1.el6.ngx.x86_64.rpm 로 설치 하면 됩니다.
nginx-1.9.4-1.el6.ngx.x86_64.rpm
nginx version: nginx/1.9.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
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-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=mod_security/nginx/modsecurity --add-module=nginx-rtmp-module --add-module=nginx-vts-module
사용 방법은 아래와 같습니다.
1. /etc/init.d/conf.d/ 에 virtualhost 설정을 작성.
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;
}
2. /etc/nginx/conf.d/modsecurity.conf에 mod_security 룰을 작성.
SecRuleEngine On
SecRequestBodyAccess On
SecResponseBodyAccess Off
SecDefaultAction phase:2,log,auditlog,deny
SecAuditLogDirMode 1733
SecAuditLogFileMode 0550
#SecAuditLogType Concurrent
#SecAuditLogStorageDir /var/log/nginx/modsec_audit/
SecDebugLog /var/log/nginx/modsec_debug.log
SecDebugLogLevel 3
SecAuditEngine RelevantOnly
SecAuditLog /var/log/nginx/modsec_audit.log
SecRule REMOTE_ADDR "^10\.0\.0\.[0-9]{1,3}$" "log,deny,id:1"
SecRule REMOTE_ADDR "^192\.168\.[0-9]{1,3}\.[0-9]{1,3}$" "log,deny,id:2"
SecRule ARGS_GET "atack" "log,deny,id:3"
SecRule ARGS_POST "evil" "log,deny,id:4"
SecRule ARGS "(\"|>|<|'|script|onerror)" "log,deny,id:5"
SecRule ARGS "foo" "log,pass,id:6"
이상입니다.
* 본 rpm은 보다 많은 분들이 편리하게 nginx 를 사용할 수 있도록 돕겠다는 취지로 제작 되었으며,
해당 소프트웨어를 사용함에 있어 본 제작자는 소프트웨어 사용중 발생할 수 있는 어떠한 문제에 대하여서도 책임을 지지 않음을 밝힙니다.
해당 소프트웨어를 사용중에 발생하는 모든 책임은 사용자에게 있습니다.
'IT 이야기 > 리눅스 Tip' 카테고리의 다른 글
CentOS 7, 'Firewalld'설정방법과 'iptables'과의 차이 中 - 일본서버호스팅 제이피서버 (0) | 2017.09.09 |
---|---|
CentOS 7, 'Firewalld'설정방법과 'iptables'과의 차이 上 - 일본서버호스팅 제이피서버 (0) | 2017.09.08 |
Linux 기본명령어 'apt' 명령어소개 - 일본서버호스팅 제이피서버 (0) | 2017.09.04 |
윈도우 응용프로그램에 해당하는 리눅스 응용프로그램 - 일본서버임대 제이피서버 (0) | 2017.08.30 |
CentOS에서 yum으로 PHP5.6 설치하기 (0) | 2017.06.02 |