简体   繁体   English

使用Apache HTTP Server提供错误页面

[英]Serve Error Pages Using Apache HTTP Server

I am using Tomcat for hosting my web application and apache http server on top of it using mod proxy for load balancing. 我正在使用Tomcat来托管我的Web应用程序和apache http服务器,使用mod代理进行负载平衡。

When my application throws a 404 or 500 error, I want to serve the error pages through apache http server rather than tomcat server. 当我的应用程序抛出404或500错误时,我想通过apache http服务器而不是tomcat服务器提供错误页面。 This is because I am serving all of my static content through apache and don't want it as part of war. 这是因为我通过apache提供所有静态内容,并且不希望它作为战争的一部分。 Is there a way to do that? 有没有办法做到这一点?

Specify the "ErrorDocument" directive in the virtualhost section of your apache config: 在apache配置的virtualhost部分中指定“ErrorDocument”指令:

ErrorDocument 404 /path/to/my404page.html
ErrorDocument 500 /path/to/my500page.html

Additionally, since you're using mod proxy, you may you may wish to enable ProxyErrorOverride to let apache generate custom error documents for proxied content. 此外,由于您正在使用mod代理,您可能希望启用ProxyErrorOverride以让apache为代理内容生成自定义错误文档。

Also check out the documentation 另请查看文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM