Apache用户认证命令解析

用户认证模块所用相关命令知识扩展

要使用用户认证功能,你需要确保mod_authn_coremod_authz_core模块在器在安装时就编译进了服务器内或者在apache主配置文件内加载上述2模块之一。

1[root@localhost ~]# grep "mod_authn_core" /usr/local/apache/conf/httpd.conf 2LoadModule authn_core_module modules/mod_authn_core.so 3 4 5[root@localhost ~]# grep "mod_authz_core" /usr/local/apache/conf/httpd.conf 6LoadModule authz_core_module modules/mod_authz_core.so

用户认证代码块举例

1<Directory "/www/docs"> 2 AuthType Basic 3 AuthName Documents 4 AuthUserFile "/usr/local/apache/passwd/passwords" 5 Require valid-user 6</Directory>

AllowOverride

语法:AllowOverride ALL|None|drective-type

默认值为None

drective-type

  • AuthConfig

    配置用户认证时指定

    表示允许使用认证相关指令如AuthName、AuthType、AuthUserFile

    AllowOverride AuthConfig

  • FileInfo

    表示允许使用如下控制命令:

    文件类型(如ErrorDocument)、文件元数据(如CookieDomain)、

    rewrite模块相关(RewriteCond)、alias模块(Redirect)、

    actions模块(Action)

    AllowOverride FileInfo

  • Indexes

    表示允许使用如下控制目录索引相关的命令:

    如AddDescription, AddIcon, AddIconByEncoding,

    AddIconByType, DefaultIcon, DirectoryIndex,

    FancyIndexing, HeaderName, IndexIgnore等

    AllowOverride Indexes

  • Limit

    表示允许使用如下控制主机访问相关的命令:

    如Allow、Deny和Order

    AllowOverride Limit

  • Options

    表示允许使用如下的诸多特殊目录结构相关的命令:

    如Options和XBitHack命令内的参数

    例如Indexes、MultiViews就是Options命令内的参数

    AllowOverride Options=Indexes,MultiViews

另外上述参数可以组合使用如:

AllowOverride AuthConfig Indexes

AuthType

语法 AuthType None | Basic | Digest | Form

前提开启AuthConfig配置AllowOverride AuthConfig

为了使用该命令,你必须同时使用AuthNameRequire命令,此外服务器还必须有一个“认证提供者”模块例如mod_authn_file和一个认证模块例如:mod_authz_user。

开启认证时如果想让某个目录内的一个目录不进行认证,就需要另外指定AuthType None来关闭认证,默认设置认证的目录下的目录会继承上级目录的设置。

  • 指定密码文件

    <Directory "/www/docs"> AuthType Basic AuthName Documents AuthBasicProvider file AuthUserFile "/usr/local/apache/passwd/passwords" Require valid-user </Directory>

  • 无密码文件

    <Directory "/www/docs/public"> AuthType None Require all granted </Directory>

Require

Require命令测试了一个认证用户是否是AuthUserFile所指定的认证文件内的用户!

  1. 所有用户无需认证:

Require all granted

  1. 所有用户认证无效:

Require all denied

  1. 只有在某个所给的环境变量被设置才允许访问:

Require env env-var

4 只有指定的HTTP方法才能访问:

Require method http-method [http-method]...

5 只有指定表达式计算为真时才能访问:

Require expr expression

6 只有指定用户才能访问:

1# Require user userid [userid]... 2Require user admin root

7 只有指定组内用户才能访问:

1# Require group group-name [group-name]... 2Require group admin

8 所有有效用户都能访问:

Require valid-user

9 指定ip网段才能访问:

1# 指定的10.172.20.0/24192.168.2.0/24网段 2Require ip 10.172.20 192.168.2

整理自Apache HTTP 服务器 2.4 文档

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )