【问题标题】:apache tomcat 503 custom error pageapache tomcat 503 自定义错误页面
【发布时间】:2011-06-07 16:36:38
【问题描述】:

我有 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 的 Document Root 是 /var/www/ 所以我将下面的条目放在 apache2.conf 文件中

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

【问题讨论】:

    标签: tomcat apache2 http-status-code-503


    【解决方案1】:

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

    我针对这个问题发布了我的工作解决方案here

    【讨论】:

      【解决方案2】:

      来自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 应该可以工作。

      【讨论】:

      • /etc/apache2/sites-enabled/000-defaults 文件中,DocumentRoot 是/var/www/ 而不是/var/www。如果我使用 /maintenance.html 而不是 maintenance.html 我将得到相同的 Server Temporarly Unavailable 错误页面。
      • server-ip/maintenance.html 一样工作,我可以在 apache 配置文件中添加 ErrorDocument 503 http://server-ip/maintenance.html 并且这工作但页面停留在维护页面中,用户必须再次将 URL 指向 myapp.mydomain.com 之后tomcat 起来了。
      • 来自 apache 文档 (httpd.apache.org/docs/2.0/mod/core.html#documentroot),DocumentRoot 应指定为不带斜杠。祝你好运!
      • maintenance.html 可以包含指向您的应用的可点击链接或对其进行定期元刷新。
      • 它只是一个普通的html程序,没有类似的东西,因为它是我创建的。
      猜你喜欢
      • 2013-02-13
      • 2014-05-14
      • 2011-01-17
      • 2012-09-29
      • 2014-02-28
      • 2019-01-18
      • 2011-04-20
      • 2011-02-28
      • 2016-01-17
      相关资源
      最近更新 更多