96818 发表于 2018-11-27 08:34:03

apache的安全设置

  apache增强型配置
1)在apache的配置文件中

       Options Indexes FollowSymLinks //建议将此处的index删除
       AllowOverride None
       Order allow,deny
       Allow from all
2)打开apache的状态页
vi /usr/local/apache2/conf/extra/httpd-info.conf

    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 192.168.10.101 //输入允许访问此信息的IP或者网段

设置ExtendedStatus On
Include conf/extra/httpd-info.conf 去掉前面的注释
浏览器访问http://192.168.10.217/server-status可以看到服务器的一些状态信息
还有一个可以查看apache的配置信息server-info
默认server-status已经被编译进了apache而server-info则没有,需要在编译的时候指定
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable

-info
3)认证网页设置
1.首先确认这些是在配置文件中存在的

    Order allow,deny
    Deny from all
    Satisfy All


      Options FollowSymLinks
      AllowOverride AuthConfig //设置访问此目录时候需要认证
      Order allow,deny
      Allow from all

2.在受保护的目录下面建立.htaccess文件
cd /usr/local/apache2/test
vi .htaccess
AuthName "Enter your password" //输入用户名和密码时候的提示字符
AuthtypeBasic                //apache的默认认证类型
AuthUserFile /usr/local/apache2/apache.passwd //使用的密码文件
require user mike            //只允许apache.passwd里面的mike用户访问
require valid-user             //所有在apache.passwd里面的用户都可以访问
3.建立账户
/usr/local/apache2/bin/htpasswd -c /usr/local/apache2/apache.passwd mike
4)设置apache的日志压缩
cd /etc/logrotate.d/
如果没有则手动建立文件vi httpd,内容如下
/var/log/httpd/*.log
{       missingok
      notifempty
      sharedscripts
      postrotate
      /bin/kill-HUP 'cat /var/run/httpd.pid 2>/dev/null||ture
      endscript
      compress            //配置日志压缩
}



页: [1]
查看完整版本: apache的安全设置