1. 程式人生 > >Apache安全<一>

Apache安全<一>

目錄 mil .html 更新 conf ref toml referer web

Apache安全

1、權限最小化

Apache用戶只能用Apache用戶去執行

查看ps -ef | grep http

2、確保只有root用戶可以修改Web根目錄下的文件

chown root:root /var/www/html

find /var/www/html -type f -exec chmod 644 {} \;

find /var/www/html type d -exec chmod 755 {} \;

3、開啟Apache的日誌記錄功能,記錄客戶端IP、訪問時間、請求頁面、發送字節數、Agent等信息。

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

CustomLog logs/access_log combined

可以根據情況修改LogFormat,記錄需要的信息。

4自定義錯誤信息

參考配置操作

建立錯誤頁面400.html401.html402.html403.html404.html等,在httpd.conf添加

ErrorDocument 400 /error/400.html

ErrorDocument 401 /error/401.html

ErrorDocument 402 /error/402.html

ErrorDocument 403 /error/403.html

ErrorDocument 404 /error/404.html

5、只允許部分IP訪問網站的敏感目錄。

參考配置操作

<Directory "/var/www/html/admin">

Order allow,deny

Allow from 192.168.0.0/255.255.255.0

</Directory>

6、禁用Apache的目錄瀏覽功能

參考配置操作

如以下配置

<Directory "/var/www/html">

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

改為

Options -Indexes FollowSymLinks

==============================================================

作者:compy    更新日期:2017-09-26 23:57    Q群:627806889

==============================================================

Apache安全<一>