ErrorDocument not working with local file
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开发者_StackOverflow社区 = /
Something isn't configured correctly but I have no I what or where. Thanks for the responses so far, but still stumped.
AllowOverride should not be None
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:
ErrorDocument 403 /usr/local/apache2/htdocs/Oops.html
Alternatively, I guess if you put it into the VirtualHost
section, it will work relatively.
ErrorDocument docs
精彩评论