• 【中间件安全】Apache 安全加固规范


    1. 适用情况

    适用于使用Apahce进行部署的Web网站。

    2. 技能要求

    熟悉Apache配置文件,能够利用Apache进行建站,并能针对站点使用Apache进行安全加固。

    3. 前置条件

    1、 根据站点开放端口,进程ID,确认站点采用Apache进行部署;

    2、 找到Apache配置文件

    4. 详细操作

    4.1 禁止目录浏览

    (1) 备份httpd.conf配置文件,修改内容:

    Options FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

    将Options Indexes FollowSymLinks 中的Indexes 去掉,就可以禁止 Apache显示该目录结构。

    (2)设置 Apache 的默认页面:

    DirectoryIndex index.html

    其中index.html即为默认页面,可根据情况改为其它文件,部分服务器需要在目录下新建空白的index.htm才能生效。

    (3)重新启动 Apache 服务

    4.2 日志配置

    (1) 备份httpd.conf配置文件,修改内容:

    Window下:

    LogFormat "%h %l %u %t "%r" %>s %b "%i" "%i"" combined

    CustomLog "|bin/rotatelogs.exe logs/localhost_access_log.%Y-%m-%d.log 86400 480" combined

    增加红色字体这一行,即可开启apache日志并且按照日期划分创建。

    (2) 重新启动 Apache 服务

    4.3 限制目录执行权限

    (1) 备份httpd.conf配置文件,修改内容:

    Order Allow,Deny

    Deny from all

    4.4 错误页面处理

    (1)备份httpd.conf配置文件,修改内容:

    ErrorDocument 400 /custom400.html

    ErrorDocument 401 /custom401.html

    ErrorDocument 403 /custom403.html

    ErrorDocument 404 /custom404.html

    ErrorDocument 405 /custom405.html

    ErrorDocument 500 /custom500.html

    其中Customxxx.html 为要设置的错误页面。

    (2)重新启动 Apache 服务生效

    4.5 最佳操作实践

    4.5.1隐藏Apache版本号

    (1) 备份httpd.conf 文件,修改内容:

    ServerSignature Off

    ServerTokens Prod

    (2) 重新启动 Apache 服务

    4.5.2限制IP访问

    (1) 备份httpd.conf配置文件,修改内容:

    Options FollowSymLinks

    AllowOverride None

    Order Deny,Allow

    Deny from all

    Allow from 192.168.204.0/24

    只允许从192.168.204.0/24 IP段内的用户访问,一般在限制后台访问时用到。

    4.6 风险操作项

    4.6.1 Apache 降权

    Linux中操作步骤为:

    备份httpd.conf文件

    修改:

    User nobody

    Group# -1

    重启 APACHE

    /apachectl restart

    Windows中操作步骤为:

    新建系统用户组www,新建系统用户apache并设置密码。

    运行services.msc打开服务管理界面,双击apache2.2服务打开属性页,点击“登录”选项卡,选择“此账户”,填写账号和密码,确定。

    4.6.2 防CC攻击

    备份httpd.conf配置文件,修改内容:

    Timeout 10

    KeepAlive On

    KeepAliveTimeout 15

    AcceptFilter http data

    AcceptFilter https data

    重新启动 Apache 服务生效

    4.6.3 限制请求消息长度

    备份httpd.conf配置文件,修改内容:

    LimitRequestBody 102400

    重启apache生效

    上传文件的大小也会受到此参数限制。

     

    最后

    欢迎关注个人微信公众号:Bypass--,每周原创一篇技术干货。 

     

     

  • 相关阅读:
    设置WebSphere字符集参数
    防SQL注入
    改变radio/checkbox默认样式
    数据完整性约束错误
    Java项目多数据源配置
    No row with the given identifier exists:错误另解
    ICTCLAS20160405分词系统调试过程
    centos7 忘记root密码
    java之Junit
    javaweb之登录
  • 原文地址:https://www.cnblogs.com/xiaozi/p/10117715.html
Copyright © 2020-2023  润新知