2010-11-21 33 views
2

我正在使用Tomcat 6.0.18上运行的Web应用程序,并将Apache 2用作反向代理。这工作正常。我也试图让Apache显示错误页面,例如,我关闭了Tomcat进行重新部署等。但是,我的httpd.conf中的ErrorDocument指令似乎对本地文件没有任何作用。我试过外部URL和字符串,这两种情况都很好。但下面不起作用:ErrorDocument不能与本地文件配合使用

ErrorDocument 403 /Oops.html 
ErrorDocument 404 /Oops.html 
ErrorDocument 502 /Oops.html 
ErrorDocument 503 /Oops.html 

Oops.html文件位于我的htdocs文件夹中。下面是一些httpd的日志输出,当我尝试访问应用程序时,Tomcat没有运行,但httpd的是:我没有使用.htaccess文件

==> access_log <== 
localhost - - [21/Nov/2010:12:23:36 -0800] "GET /home HTTP/1.1" 503 - 

==> error_log <== 
[Sun Nov 21 12:23:36 2010] [debug] mod_proxy_http.c(54): proxy: HTTP: canonicalising URL //localhost:8080/home 
[Sun Nov 21 12:23:36 2010] [debug] proxy_util.c(1412): [client ::1] proxy: http: found worker http://localhost:8080/ for http://localhost:8080/home 
[Sun Nov 21 12:23:36 2010] [debug] mod_proxy.c(819): Running scheme http handler (attempt 0) 
[Sun Nov 21 12:23:36 2010] [debug] mod_proxy_http.c(1693): proxy: HTTP: serving URL http://localhost:8080/home 
[Sun Nov 21 12:23:36 2010] [debug] proxy_util.c(1790): proxy: HTTP: retrying the worker for (localhost) 
[Sun Nov 21 12:23:36 2010] [error] proxy: HTTP: disabled connection for (localhost) 
[Sun Nov 21 12:23:36 2010] [debug] mod_proxy_http.c(54): proxy: HTTP: canonicalising URL //localhost:8080/Oops.html 
[Sun Nov 21 12:23:36 2010] [debug] proxy_util.c(1412): [client ::1] proxy: http: found worker http://localhost:8080/ for http://localhost:8080/Oops.html 
[Sun Nov 21 12:23:36 2010] [debug] mod_proxy.c(819): Running scheme http handler (attempt 0) 
[Sun Nov 21 12:23:36 2010] [debug] mod_proxy_http.c(1693): proxy: HTTP: serving URL http://localhost:8080/Oops.html 
[Sun Nov 21 12:23:36 2010] [debug] proxy_util.c(1790): proxy: HTTP: retrying the worker for (localhost) 
[Sun Nov 21 12:23:36 2010] [error] proxy: HTTP: disabled connection for (localhost) 

注意。似乎与htdocs文件夹有关的设置存在一些问题。下面是我的httpd.conf文件中与htdocs foler有关的一些内容。我刚刚与Apache合作,所以我不确定这是多么相关,或者我应该发布更多。

<Directory "/usr/local/apache2/htdocs"> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Order allow,deny 
    Allow from all  
</Directory> 

任何帮助非常感谢!

编辑:

当Tomcat运行我看到错误日志中的这些行:

[Sun Nov 21 13:30:11 2010] [error] [client ::1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3046): [client ::1] r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri = /Oops.html 
[Sun Nov 21 13:30:11 2010] [debug] core.c(3052): [client ::1] redirected from r->uri =/

东西是不正确配置,但我没有什么我或者。感谢迄今为止的回应,但仍然难倒。

+0

你有一定的RewriteRules某处沿线,也许在一个目录进一步上涨的树或配置? ....虽然在第二个想法,这可能是一个递归,因为它没有找到404文档,然后没有找到404文档,依此类推...... – 2010-11-21 21:40:27

+0

检查是'DocumentRoot' +'/Ops.html' ='/ usr/local/apache2/htdocs/Ops.html'?有人认为你正在使用不同的DocumentRoot – ajreal 2010-11-21 21:47:53

+0

@ajreal:我禁用了所有代理并删除了错误文档指令并重新启动。我能够访问我设置为DocumentRoot的目录中的其他几个页面,因此似乎设置正确。 – richever 2010-11-21 22:04:36

回答

0

如果在中央配置中指定,Apache可能将该路径视为绝对路径,在根目录中查找Oops.html。尝试使用完整路径:

ErrorDocument 403 /usr/local/apache2/htdocs/Oops.html 

另外,我想如果你把它放到VirtualHost部分,它会比较工作。

ErrorDocument docs

+0

我已经尝试了你的两个建议,甚至组合,我仍然没有得到任何东西。不过谢谢。 – richever 2010-11-21 21:11:48

+0

@richever奇怪。你确定Web服务器有权限读取文件吗? – 2010-11-21 21:22:12

+0

我已经尝试了该目录中的其他文件,并chmod'ed它,以便它应该可访问,但仍然没有。我要编辑我的帖子,在错误日志中提到一些可疑的行,指向一些错误的配置。 – richever 2010-11-21 21:33:22

1

的AllowOverride不应该是无

+0

已经在配置中设置了吗? – 2013-02-20 19:00:05

相关问题