2011-01-12 161 views
5

我有apache2和tomcat6(没有从apt库中安装,手动下载并安装)在端口80上运行,mod_jk设置。访问jsp servlet页面,将浏览器指向http://myapp.mydomain.com/(虚拟主机在tomcat(server.xml)和apache中完成)。在部署期间,当tomcat关闭(pkill -9 java或/etc/init.d/tomcat stop)时,我试图将tomcat的错误页面503重定向到自定义错误页面。apache tomcat 503自定义错误页面

我的Apache的文档根目录为/ var/WWW /所以我把下面的条目apache2.conf文件

ErrorDocument 503 maintenance.html和创建在/ var/WWW文件maintenance.html。当我测试停止tomcat时,我将页面重定向到maintenance.html,但没有更改url,但实际页面未显示,而是在浏览器上显示文件名maintenance.html。任何人可以帮助我正确地配置Apache重定向到正确的maintenance.html页面,当tomcat关闭?

回答

4

apache documentation

URLs can begin with a slash (/) for local web-paths (relative to the 
DocumentRoot), or be a full URL which the client can resolve. 

我想ErrorDocument 503 /maintenance.html应该工作。

+0

在`/等/ apache2的//000-defaults`文件DocumentRoot的是'在/ var/WWW /`启用站点,而不是'在/ var/www` 。如果我使用`/ maintenance.html`而不是`maintenance.html`,我会得到相同的`Server Temporarly Unavailable`错误页面。 – user465465 2011-01-12 10:44:34

0

如果您使用Apache与Tomcat连接器,该解决方案比简单添加和ErrorDocument指令稍微复杂一些。您必须明确告诉Apache不要在/maintenance.html文件的挂接连接器中查找;相反,它需要在本地寻找它。

我贴我的工作解决这个问题here