【问题标题】:Getting a 403 forbidden error for simplesaml after Apache upgradeApache 升级后,simplesaml 出现 403 禁止错误
【发布时间】:2014-06-13 18:49:42
【问题描述】:

在我在 Ubuntu 上将 Apache 升级到 2.4.6 之前,我的 simplesaml 一直运行良好

我得到的错误:

Forbidden

You don't have permission to access /simplesaml/ on this server.

【问题讨论】:

    标签: simplesamlphp


    【解决方案1】:

    在 Apache 上安装 simplesamlphp 的说明只需要 simplesamlphp 目录的别名:

    https://simplesamlphp.org/docs/stable/simplesamlphp-install#section_6

    但是对于 Apache 2.4.6+,安全性发生了变化——当我添加目录指令时它对我有用。例如:

    <VirtualHost *:80>
        ServerName mywebsite.dev
        DocumentRoot /home/myuser/www/mywebsite/
    
        <Directory /home/myuser/www/mywebsite/>
            Require all granted
        </Directory>
    
        Alias /simplesaml /var/simplesamlphp/www
    
        <Directory /var/simplesamlphp/www/>
            Require all granted
        </Directory>
    
    </VirtualHost>
    

    【讨论】:

    • 你解决了这个问题吗?我在 MAMP PRO 上遇到了同样的错误。我更改了 /var/simplesaml 的所有者和组,但没有奏效。我尝试了 777 但没有成功。
    • 是的,上面的答案是解决方案 - 您需要添加 语句以获得所有已授予的权限
    【解决方案2】:

    虽然选择的答案是正确的,但我想补充一点,SELinux 也可能导致此错误。在网上浏览了大量示例后,我花了几个小时才意识到这是我的问题。

    如果您正在运行 SELinux,请确保您运行以下命令:

    chcon -R --reference=/var/www /var/simplesamlphp
    

    这会将/var/simplesamlphp 目录置于与/var/www 相同的安全上下文中。您不能只将/var/simplesamlphp/www 目录放在同一上下文中,因为_include.php 访问/var/simplesamlphp/lib 中的文件。

    我希望这可以防止有人像我一样在这个问题上花费太多时间。

    【讨论】:

      【解决方案3】:

      如果您通过 compose 安装了 simplesamlphp,这可能会更复杂。除了@RusselEngland's answer 需要添加正确的 Apache 配置之外,如果您仍然收到 403,您需要确保该文件没有被 .htaccess 中的规则阻止。

      Apache 配置:

      <VirtualHost *:80>
          DocumentRoot /var/www/html
      
          Alias /simplesaml /var/www/html/vendor/simplesamlphp/simplesamlphp/www
      
          <Directory /var/www/html/vendor/simplesamlphp/simplesamlphp/www/>
              Require all granted
          </Directory>
      </VirtualHost>
      

      .htaccess(在 /var/www/html 中);

      <IfModule mod_rewrite.c>
          #...
          RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
          RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
          RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
          RewriteCond %{REQUEST_URI} !^/simplesaml/*  # Add this condition
          RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
      </IfModule>
      

      【讨论】:

        猜你喜欢
        • 2013-09-07
        • 2013-08-29
        • 2015-08-19
        • 1970-01-01
        • 2013-10-29
        • 2021-12-17
        • 2015-06-03
        • 2016-01-12
        • 2013-07-19
        相关资源
        最近更新 更多