【问题标题】:Allow IP address without authentication允许 IP 地址无需身份验证
【发布时间】:2011-04-08 16:04:13
【问题描述】:

我已经建立了一个网站,目前正在进行中。我正在使用需要访问我服务器上的脚本的外部 SMS 网关。但是,我已经为普通用户设置了基本的用户名和密码认证,但是短信网关无法通过。

如何允许单个 IP 通过身份验证而不对其自身进行身份验证,并拒绝所有其他未通过身份验证的用户?

这是我的.htaccess 文件:

Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /www/.site_htpasswd
AuthName "Protected Area"
require user admin

【问题讨论】:

    标签: authentication .htaccess


    【解决方案1】:

    更新: 从 Apache 2.4 开始,OrderAllowDenySatisfy 指令 should not be used anymore。所以新的语法是:

    AuthType Basic
    AuthUserFile /www/.site_htpasswd
    AuthName "Protected Area"
    
    <RequireAny>
        Require ip 1.2.3.4
        Require valid-user
    </RequireAny>
    

    【讨论】:

      【解决方案2】:

      在 JoseK 的帮助下刚刚发现:

      Order deny,allow
      Deny from all
      AuthType Basic
      AuthUserFile /www/.site_htpasswd
      AuthName "Protected Area"
      require valid-user
      Allow from 1.2.3.4
      Satisfy Any
      

      【讨论】:

      • 那是什么 Apache 和 mod_auth 版本?
      • 这应该适用于 Apache 2.2。 Apache 2.4 有new syntax
      【解决方案3】:

      尝试将前 2 行更改为

      Order deny,allow
      Deny from all
      Allow from 1.2.3.x
      

      Allow from中替换你想要的IP

      【讨论】:

      • 这只是给了我一个 403 Forbidden :/
      • 没关系,我有一个错误.. :P 但是,现在它只是一直要求我进行身份验证,并且不想在我输入凭据时对我进行身份验证。
      猜你喜欢
      • 2018-05-03
      • 2012-12-09
      • 1970-01-01
      • 1970-01-01
      • 2018-04-30
      • 1970-01-01
      • 2014-02-19
      • 2015-12-25
      • 1970-01-01
      相关资源
      最近更新 更多