【问题标题】:Apache Http Basic Authentication - Forbidden Error 403Apache Http 基本身份验证 - 禁止错误 403
【发布时间】:2015-12-02 06:15:16
【问题描述】:

我正在执行基本身份验证以通过调度程序访问网页。我浏览了一些博客并且能够实现它,但仅限于一个目录。下面是我配置的虚拟主机。

    <VirtualHost *:80>
    ServerAdmin admin@aemcorner.com
    ServerName aemcorner.com
    ServerAlias www.aemcorner.com
    #DocumentRoot /var/www/example.com/public_html
        DocumentRoot /opt/communique/dispatcher/cache
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
       <Directory /content/practice/en/hello/secure-pages>
   # <Directory /var/www/example.com/public_html>
          AuthType Basic
          AuthName "Secure Content"
          AuthBasicProvider file
          AuthUserFile /etc/apache2/passwords
          Require all granted
        </Directory>
</VirtualHost>

在这里我想使用注释行,这个 sn-p 工作正常,但是当我 用 /content/practice/en/Secure-Pages 替换它并使用注释的 DocumentRoot 它给我一个错误如下:

**Forbidden
You don't have permission to access /content/practice/en/hello/secure-pages/sp1.html on this server.**

我想访问页面/opt/communique/dispatcher/cache/content/practice/en/Secure-Pages/SP1.html

我也收到以下错误:

[Mon Sep 07 20:57:39.500158 2015] [authz_core:error] [pid 9483:tid 140017092585216] [client 127.0.0.1:49543] AH01630: client denied by server configuration: /opt/communique/dispatcher/cache/favicon.ico, referer: http://aemcorner.com/content/practice/en/hello/secure-pages/sp1.html

【问题讨论】:

  • 您尝试访问的文件的路径不在您尝试允许访问的目录的路径中。还要确保您与区分大小写一致。试试改成&lt;Directory /content/practice/en/hello/secure-pages&gt;
  • 是的,我这样做了,当我点击aemcorner.com/content/practice/en/hello/secure-pages/sp1.html url 时,它给了我同样的信息你没有访问/content/practice/en/hello/secure-pages/sp1.html 的权限在这台服务器上。更新问题也

标签: linux apache authentication webserver http-authentication


【解决方案1】:

我可以通过以下配置解决这个问题:

<VirtualHost *:80>
    ServerAdmin admin@aemcorner.com
    ServerName aemcorner.com
    ServerAlias www.aemcorner.com
    #DocumentRoot /var/www/example.com/public_html
        DocumentRoot /opt/communique/dispatcher/cache
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
       <Location /content/practice/en/hello/secure-pages>
   # <Directory /var/www/example.com/public_html>
          AuthType Basic
          AuthName "Secure Content"
          AuthBasicProvider file
          AuthUserFile /etc/apache2/passwords
          Require valid-user
        </Location>
</VirtualHost>

我使用 Location 代替 Directory 和 Require valid-user

【讨论】:

    猜你喜欢
    • 2019-05-12
    • 2011-05-05
    • 2015-09-05
    • 1970-01-01
    • 2019-10-24
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多