为什么Apache禁止我访问此页面?

时间:2013-07-29 12:02:53

标签: apache

直到最近,内部Bugzilla安装工作正常。现在,对http://example.com/bugzilla目录中的页面的所有请求都返回403/Forbidden。该目录之外的页面,例如http://example.com/test.htmlhttp://example.com/test/index.html处的页面按预期工作。这是.htaccess目录的bugzilla文件,与原始文件保持不变:

# Don't allow people to retrieve non-cgi executable files or our private data

<FilesMatch (\.pm|\.pl|\.tmpl|localconfig.*)$>
  deny from all
</FilesMatch>

<IfModule mod_expires.c>
    <IfModule mod_headers.c>
        <IfModule mod_env.c>
          <FilesMatch (\.js|\.css)$>
            ExpiresActive On
            # According to RFC 2616, "1 year in the future" means "never expire".
            # We change the name of the file's URL whenever its modification date
            # changes, so browsers can cache any individual JS or CSS URL forever.
            # However, since all JS and CSS URLs involve a ? in them (for the changing
            # name) we have to explicitly set an Expires header or browsers won't
            # *ever* cache them.
            ExpiresDefault "now plus 1 years"
            Header append Cache-Control "public"
          </FilesMatch>

          # This lets Bugzilla know that we are properly sending Cache-Control
          # and Expires headers for CSS and JS files.
          SetEnv BZ_CACHE_CONTROL 1
        </IfModule>
    </IfModule>
</IfModule>

AddHandler cgi-script .cgi .pl
DirectoryIndex index.cgi

这是.htaccess目录上方目录的bugzilla文件。这是public_html网络根目录:

DirectoryIndex index.html

这是该站点的Apache配置文件:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/default/public_html
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/default/public_html>
        DirectoryIndex index.cgi
        AllowOverride Limit FileInfo Indexes
        AddHandler cgi-script .cgi
        Options Indexes FollowSymLinks MultiViews +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

请注意,即使该目录中的非Bugzilla静态HTML文件也会受到影响。例如,我在VIM中创建/bugzilla/test.html,然后我尝试在浏览器中访问它,并看到它也返回403/Forbidden。该目录内外的所有文件都具有相同的用户ubuntu和相同的权限644bugzilla目录本身具有权限755,其父public_html也是如此。

服务器上没有安装Plesk等“控制面板”,所有配置都在Apache配置文件中完成。为什么Apache决定我可能无权查看bugzilla目录?这是在Amazon Web Services上托管的公共Web服务器上,位于Ubuntu Server 12.04 LTS上。

2 个答案:

答案 0 :(得分:1)

检查error_log文件,它通常有非常详细的信息,说明它返回403 Forbidden的原因。

答案 1 :(得分:1)

(它看起来像debian服务器?如果您发布这样的问题,请务必提及操作系统。)

我怀疑这是一个权利问题 - 错误的所有者。对于debian / ubuntu,给定文件夹及其文件应归用户“www-data”所有。对于Centos / Redhat,我认为应该是“没人”。检查一下,必要时进行更改。

sudo chown -R www-data:www-data test

注意:如果您不确定更改权利,请先复制一份。更改副本的所有者,因为复制本身可能会更改所有者。或者使用rsync制作文件夹的副本,因为rsync会保留所有者和权限。