【问题标题】:Litespeed Enterprise not obeying .htaccess require rulesLitespeed Enterprise 不遵守 .htaccess 要求规则
【发布时间】:2022-01-02 16:50:58
【问题描述】:

我有以下文件夹结构

domain.com (/public_html/)
sub.domain.com (/public_html/sub/)
sub.domain.com/dir1/ (/public_html/sub/dir1/)
sub.domain.com/dir1/dir2/ (/public_html/sub/dir1/dir2/)

如果我将以下内容放在我的 .htaccess 文件中的任何这些目录中

DirectoryIndex index.php

require valid-user
<RequireAny>
    Require ip x.x.x.x
</RequireAny>

加载这些目录中的任何文件时都没有效果。

另外,如果我希望拥有多个 require 规则和/或它会变得更复杂一些,例如

# Allowing Access via Password or one of the following IP Addresses

AuthName "Authorized Only"
AuthType Basic
AuthUserFile /home/.htpasswds/.htpasswd

<RequireAll>
require valid-user
<RequireAny>
    Require ip x.x.x.x
    Require ip y.y.y.y
</RequireAny>
</RequireAll>

Apache 确实遵循了这些规则集,但切换到 litespeed 企业网络服务器意味着 IP 限制已被忽略

我在这里错过了什么?

【问题讨论】:

  • 你在这个.htaccess 文件中还有其他指令吗?文件系统路径上还有其他.htaccess 文件吗?在 LiteSpeed 上,模块以不同的顺序执行,因此您会发现 mod_rewrite(例如)最终会覆盖 mod_authz_core(和相关的身份验证模块) - 而在 Apache 上则相反。
  • 每个级别都有 .htaccess 文件,以允许自定义访问每个目录以访问一系列 IP 地址。例如,我可能希望只有会计办公室能够访问 /organisation/accounts/ 而他们和总部可以访问 /organisation/
  • 会满足任何人并满足所有人的解决方案吗?

标签: apache .htaccess litespeed


【解决方案1】:
require valid-user
<RequireAny>
    Require ip x.x.x.x
</RequireAny>

这对于 Apache 2.4 来说似乎有点过头了。 &lt;RequireAny&gt; 是默认容器。以上4行与Require ip x.x.x.x一行相同。

但是,我对 LiteSpeed 的体验是,它的行为更像 Apache 2.2 服务器,并且(令人讨厌)默默地在它不理解的指令上失败(尽管服务器的错误日志中可能记录了一些内容) )。

请尝试以下(Apache 2.2 风格)指令:

Order Allow,Deny
Allow from x.x.x.x

【讨论】:

  • 我在上面添加了更多代码来解释我为什么使用 因为我实际上列出了多个 IP。 功能允许我组合密码和/或 IP 地址限制,但是 Order Allow,Deny Allow from x.x.x.x 不会给我这个功能吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多