美文网首页
httpd的访控

httpd的访控

作者: 尘曦的雨 | 来源:发表于2017-08-02 16:38 被阅读11次
    • 设置在/var/www/html 没有默认目录是访问时不显示文件列表
    #
    <Directory "/var/www/html">
    
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
        Options -Indexes FollowSymLinks
    #表示在没有默认主页情况下以文件列表方式显示文件;如果显示就  Options -Indexes FollowSymLinks 这样就不会显示了或者把此行注
    释掉
    
                                                                                                           355,5         34%
    
    • 重启服务
      [root@root html]# service httpd restart
    • 客户端访问不会显示了

    设置自定义网页目录的如guo

    • 设置访问控制
    # symbolic links and aliases may be used to point to other locations.
    #
    DocumentRoot "/app/www/html"
    #设置网页的家目录; 更改家目录为/app/www/html
    
    #
    # Each directory to which Apache has access can be configured with respect
    # to which services and features are allowed and/or disabled in that
    # directory (and its subdirectories). 
    #
    # First, we configure the "default" to be a very restrictive set of 
    # features.  
    #
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    
    #
    # Note that from this point forward you must specifically allow
    # particular features to be enabled - so if something's not working as
    # you might expect, make sure that you have specifically enabled it
    # below.
    #
    
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    #<Directory "/var/www/html">
    <Directory "/app/www/html">
    Options Indexes FollowSymLinks
    #Indexes定义了/app/www/html 网页主目录没有,就会显示文件目录;默认是关闭的;None
    #FollowSymLinks 是定义允许软连接;不加默认是允许的;
    #None是全部禁止;All全部允许
    </Directory>
    #
    

    测试


    是否允许在

    <Directory "/app/www/html">
    Options Indexes
    #定义了/app/www/html 网页主目录没有,就会显示文件目录
    AllowOverride All
    #这个指令定义了是否允许在数据目录下创建.与访问控制相关的哪些指令可以放在指定目录下的.htaccess (由AccessFileName 指定)文
    件中,覆盖之前的配置指令只对<directory> 语句有效AllowOverride All:  所有指令都有效AllowOverride None :.htaccess  文件无>
    效AllowOverride AuthConfig Indexes  除了AuthConfig和Indexes</Directory>
    

    限制来源地址访问的资源

    #
    # The following lines prevent .htaccess and .htpasswd files from being 
    # viewed by Web clients. 
    #
    <Files ~ "^\.ht">
    #定义了以.ht开头的文件是否访用户看到 
       Order allow,deny 
    #定义允许拒绝生效顺序
        Deny from all
    #表示拒绝所有;他支持的参数有deny from 172.16. 100.100 allow from 172.16
        Satisfy All
    </Files>
    

    定制日志的信息

    • 自己定义日志格式

    字符集格式

    支持的字符集有
    中文字符集:GBK, GB2312, GB18030


    相关文章

      网友评论

          本文标题:httpd的访控

          本文链接:https://www.haomeiwen.com/subject/qzhelxtx.html