错误文档不适用于本地文件
我正在开发一个在 Tomcat 6.0.18 上运行的 Web 应用程序,并且使用 Apache 2 作为反向代理。这很好用。我还尝试让 Apache 在例如我关闭 Tomcat 进行重新部署等时显示错误页面。但是,我的 httpd.conf 中的 ErrorDocument
指令似乎不起作用全部用于本地文件。我尝试过外部网址和字符串,这两种情况都工作正常。但以下内容不起作用:
ErrorDocument 403 /Oops.html
ErrorDocument 404 /Oops.html
ErrorDocument 502 /Oops.html
ErrorDocument 503 /Oops.html
Oops.html 文件位于我的 htdocs 文件夹中。以下是当我在 Tomcat 未运行但 httpd 运行时尝试访问应用程序时 httpd 的一些日志输出:
==> 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)
请注意,我没有使用 .htaccess 文件。看来 htdocs 文件夹相关的设置有问题。下面是我的 httpd.conf 文件中与 htdocs 文件夹有关的一些内容。我是 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 = /
某些内容配置不正确,但我不知道是什么或在哪里。感谢到目前为止的回复,但仍然很困惑。
I am working on a web app that I'm running on Tomcat 6.0.18, and I am using Apache 2 as a reverse proxy. This works fine. I'm also trying to get Apache to display error pages when, for example, I've shutdown Tomcat for redeployment etc. However, the ErrorDocument
directive in my httpd.conf doesn't seem to work at all for local files. I've tried external urls and strings and both of these cases work fine. But the below does not work:
ErrorDocument 403 /Oops.html
ErrorDocument 404 /Oops.html
ErrorDocument 502 /Oops.html
ErrorDocument 503 /Oops.html
The Oops.html file is in my htdocs folder. Here is some log output from httpd when I try accessing app when Tomcat is not running but httpd is:
==> 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)
Note that I'm not using an .htaccess file. It seems that there is some problem with the settings related to htdocs folder. Below are some bits from my httpd.conf file that has to do with the htdocs foler. I'm new to working with Apache so I'm not sure how relevant this is or if I should post more.
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Any help much appreciated!
EDIT:
When Tomcat is running I see these lines in the error log:
[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 = /
Something isn't configured correctly but I have no I what or where. Thanks for the responses so far, but still stumped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AllowOverride 不应为 None
AllowOverride should not be None
如果在中央配置中指定,Apache 可能会将路径视为绝对路径,在根目录中查找
Oops.html
。尝试使用完整路径:或者,我想如果将其放入
VirtualHost
部分,它会相对有效。ErrorDocument 文档
If specified in the central configuration, Apache will probably treat the path as absolute, looking for
Oops.html
in the root directory. Try using a full path:Alternatively, I guess if you put it into the
VirtualHost
section, it will work relatively.ErrorDocument docs