Apache - Một số nguyên tắc bảo mật
Bảo mật Apache
Ngồi rảnh, viết tổng kết Apache. Tuy nhiên Công nghệ còn tiến dài. còn cập nhật nhiều.
Bảo mật Apache.
1. Sử dụng phiên bản mới nhất (latest version). Mới ở đây là stable version. Thườg xuyên update.
Khi cài đặt, nên get từ httpd.org, cài từ source, check signature nếu cần.
2. Hide Apache Version number:
Trong httpd.conf
ServerSignature Off ( Tắt tính năng hiển thị phiên bản ở các trang default, như trang lỗi 404)
ServerTokens Prod (Khi đó trong Http Response Header sẽ có Server: Apache )
3. Đảm bảo apache chạy dưới user, group đc kiểm soát.
User apache
Group apache
Ko dùng nobody. Tốt nhất là sử dụng suexec .Thêm cả suPhp hoặc suHosin cho php
4. Đảm bảo apache ko thể truy xuất ra khỏi thư mục docroot của web
Order Deny,Allow
Deny from all
Options None
AllowOverride NoneOrder Allow,Deny
Allow from all
Set Options None và AllowOverride None sẽ turn off all options và overrides.
5. Turn off directory browsing
Set Options thành None hoặc -Indexes
VD: Options -Indexes
6. Turn off server side includes
Set Options thành None hoặc -Includes
VD: Options -Includes
7. Turn off CGI execution
Ko dùng thì tắt, để nó chết có ngày.
Set Options thành None hoặc -ExecCGI
VD: Options -ExecCGI
8. Don't allow apache to follow symbolic links
Set Options thành None hoặc -FollowSymLinks
VD: Options -FollowSymLinks
9. Turning off multiple Options
Options None
hoặc: Options -ExecCGI -FollowSymLinks -Indexes
10. Turn off support for .htaccess files
Dùgn để tránh bypass
VD: AllowOverride None
Trường hợp muốn sử dụng .htaccess, đổi tên thành .httpdoverride, block tất cả truy cập vào file đó.
AccessFileName .httpdoverride
Order allow,deny
Deny from all
Satisfy All
11. Run mod_security
12. Disable any unnecessary modules
13. Đảm bảo root được truy cập vào apache's config và binaries
chown -R root:root /usr/local/apache
chmod -R o-rwx /usr/local/apache
14. Lower the Timeout value
Timeout 45
15. Limiting large requests
Hạn chế DDOS, các injection:
VD: Ko cho upload quá 1mb
LimitRequestBody 1048576
16. Limiting the size of an XML Body
LimitXMLRequestBody 10485760
17. Limiting Concurrency
18. Restricting Access by IP
19. Hiệu chỉnh KeepAlive settings
20. Chạy apache Chroot
Khi post lên, mình chưa chính sửa lại, mất một số đoạn: lấy bản text tại: http://www.mediafire.com/?umngoenmjyl
---------------------------------------------------
Thanks Administrator diendanmaychu.vn, a có nhiều bài tìm kiếm hay lắm
------------------------------
Thanks for reading
--------------------------------------------------------------------------
All my Lab:
Linux Lab -- window and Cisco Lab
to be continued - I will update more.
Nam Habach