Bảo mật website mã nguồn mở Linux với Mod_Security
Đối với một mã nguồn mở như hosting Linux thì việc bảo mật web rất là quan trọng, vì ở đây có chứa khá nhiều lỗ hổng cho hacker lọt vào. Do vậy ngoài việc...
## For RHEL/CentOS 6.2/6.1/6/5.8 ##
# yum install gcc make
# yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel
## For Fedora 17,16,15,14,13,12 ##
# yum install gcc make
# yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel
## For RHEL/CentOS 6.2/6.1/6/5.8 ##
# cd /usr/src
# wget http://www.modsecurity.org/download/modsecurity-apache_2.6.6.tar.gz
# tar xzf modsecurity-apache_2.6.6.tar.gz
# cd modsecurity-apache_2.6.6
# ./configure # make install # cp modsecurity.conf-recommended /etc/httpd/conf.d/modsecurity.conf ## For Fedora 17,16,15,14,13,12 ##
# cd /usr/src
# wget http://www.modsecurity.org/download/modsecurity-apache_2.6.6.tar.gz
# tar xzf modsecurity-apache_2.6.6.tar.gz
# cd modsecurity-apache_2.6.6
# ./configure
# make install
# cp modsecurity.conf-recommended /etc/httpd/conf.d/modsecurity.conf
Mod security này yêu cầu cần phải có OWASP (Open Web Application Security Project) để tạo cấu hình đầu tiên, các rules này dùng để bảo vệ website của bạn khỏi các nguy cơ chưa được định nghĩa và được tìm ra trong quá trình phát triển các website và do nghiên cứu, vì thế việc cài các rules này là việc làm khá quan trọng, các bạn cài như sau:
## For RHEL/CentOS 6.2/6.1/6/5.8 ##
# cd /etc/httpd/
# wget http://pkgs.fedoraproject.org/repo/pkgs/mod_security_crs/modsecurity-crs_2.2.5.tar.gz/aaeaa1124e8efc39eeb064fb47cfc0aa/modsecurity-crs_2.2.5.tar.gz
# tar xzf modsecurity-crs_2.2.5.tar.gz
# mv modsecurity-crs_2.2.5 modsecurity-crs # cd modsecurity-crs
# cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf ## For Fedora 17,16,15,14,13,12 ##
# cd /etc/httpd/
# wget http://pkgs.fedoraproject.org/repo/pkgs/mod_security_crs/modsecurity-crs_2.2.5.tar.gz/aaeaa1124e8efc39eeb064fb47cfc0aa/modsecurity-crs_2.2.5.tar.gz
# tar xzf modsecurity-crs_2.2.5.tar.gz
# mv modsecurity-crs_2.2.5 modsecurity-crs
# cd modsecurity-crs
# cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf
Tiếp theo, bạn mở FTP lên và edit file httpd.conf theo đường dẫn:
/etc/httpd/conf/httpd.conf
Tìm tới các dòng đầy chữ load module ấy, thêm dòng này:
LoadModule security2_module modules/mod_security2.so
Tiếp theo, các bạn tụt xuống gần cuối file, thêm đoạn [code] load mod này vào:
<IfModule security2_module> Include conf.d/modsecurity.conf </IfModule>
Và cuối cùng là restart lại [Apache] để nó nhận mod này thôi:
# /etc/init.d/httpd restart
Hoặc
service httpd restart
Kiểm tra bằng cách gọi hàm phpinfo() lên, các bạn sẽ thấy có thông báo module đã được load cùng php nhé
Hy vọng với ứng dụng này bạn sẽ thực hiện bảo mật web của mình tốt hơn. Xem thêm các hướng dẫn bảo mật web của Vivicorp.
Mod security này yêu cầu cần phải có OWASP (Open Web Application Security Project) để tạo cấu hình đầu tiên, các rules này dùng để bảo vệ website của bạn khỏi các nguy cơ chưa được định nghĩa và được tìm ra trong quá trình phát triển các website và do nghiên cứu, vì thế việc cài các rules này là việc làm khá quan trọng, các bạn cài như sau:
Tiếp theo, bạn mở FTP lên và edit file httpd.conf theo đường dẫn:
Tìm tới các dòng đầy chữ load module ấy, thêm dòng này:
Tiếp theo, các bạn tụt xuống gần cuối file, thêm đoạn [code] load mod này vào:
Và cuối cùng là restart lại [Apache] để nó nhận mod này thôi:
Kiểm tra bằng cách gọi hàm phpinfo() lên, các bạn sẽ thấy có thông báo module đã được load cùng php nhé
Hy vọng với ứng dụng này bạn sẽ thực hiện bảo mật web của mình tốt hơn. Xem thêm các hướng dẫn bảo mật web của Vivicorp.