Apache 基本身份验证(允许的除外)

标签 apache authentication basic-authentication

问题:我在/var/www/files/下有一些文件,我希望它们可以从特定的 IP 地址访问而无需用户/密码。但是,我希望任何其他 IP 地址都应该需要登录才能访问。

这是在我的 httpd.conf 中:

<Directory /var/www/files/>
        Order deny,allow
        Deny from all
        Allow from 192.168 
        AuthUserFile /etc/apache2/basic.pwd 
        AuthName "Please enter username and password" 
        AuthType Basic 
        Require user valid-user 
</Directory>

但是,如果我理解正确,这意味着来自 192.168.* 的任何客户端都可以访问该目录,但需要有效用户才能查看其内容。任何其他 IP 地址都将被拒绝。对?

先感谢您。

最佳答案

编辑 :这可能是可以接受的答案,但很旧。对于新的 Apache 安装,请使用 Brians answer here

添加这个:Satisfy Any (这意味着应该通过这两个中的任何一个)。

语法是:

Require valid-user

或者:
Require user <userid>

关于Apache 基本身份验证(允许的除外),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4102763/

相关文章:

ruby-on-rails - 在哪里可以存储在 Rails 的 http_basic_authentication_with 中使用的密码/用户名组合?

angular - 如何在angular2中弹出浏览器的默认基本身份验证对话框

Apache 重定向到另一个端口

apache - 无法识别一个网站如何重定向到另一个网站

asp.net-mvc - 部署后 ASP.NET Identity 2 重新登录

git - Maven 发布插件 git 凭据

http - URL中的 '@'是什么意思?

javascript - Backbone.js 和 mod 重写

javax - getSession 返回 null

java - 使用 LDAP 的 Windows 密码身份验证