Apache-Weblogic 404 配置 [英] Apache-Weblogic 404 configuration
问题描述
我已经搜索了很多,发现了类似的问题,但并不完全相同,但如果这是一个重复的问题,我深表歉意.
I've searched around for this quite a bit and found similar questions but not exactly the same, but nonetheless I apologize if this is a duplicate question.
基本上,当我的应用程序关闭时,我尝试使用自定义错误页面(即 404.html)处理 HTTP 错误响应(即 404),但 weblogic 仍在运行.
Basically, I am trying to handle HTTP error responses (i.e. 404) with a custom error page (i.e. 404.html) when my application is down, but weblogic is still up.
我将 Apache 2.2 与 weblogic 模块一起使用.我已经为 Apache 设置了 ErrorDocument 指令以及块内的 ErrorPage 参数.
I am using Apache 2.2 with the weblogic module. I have set the ErrorDocument directive for Apache as well as the ErrorPage parameter within the block.
我还在 web.xml 中为我的应用程序设置了位置,但这个问题是针对应用程序何时关闭的.
I have also set the location within my web.xml for my application, but this question is for when the application is down.
目前,当应用程序关闭并且 weblogic 正在运行时,我得到了 weblogic 默认的 404 页面.如何强制 apache 和/或 weblogic 使用我的自定义页面?
Currently, when the app is down and weblogic is running I am getting the weblogic default 404 page. How can I force apache and/or weblogic to use my custom page?
这是我尝试过的一种配置变体的示例.
Here is a sample of one variation of the config that I have tried.
<IfModule mod_weblogic.c>
WebLogicCluster host:port,host:port
KeepAliveEnabled ON
WLProxySSL OFF
Debug ALL
ErrorPage http://host:port/errors/errorSystem.html
</IfModule>
我可以直接访问错误页面,但不会在出现错误时转发流量.
I can access the error page directly, but traffic is never forwarded on error.
我还尝试将 ErrorPage 设置为相对 url,这是理想的解决方案.
I've also tried to set the ErrorPage to a relative url which is the ideal solution.
推荐答案
根据 WebLogic 文档,带有 ErrorPage 参数,当后端服务器返回 HTTP 503/服务不可用响应,并且没有用于故障转移的服务器.".
According to WebLogic documentation, with ErrorPage parameter, "The plug-in redirects to an error page when the back-end server returns an HTTP 503/Service Unavailable response and there are no servers for failover.".
因此来自 WebLogic 的 404 错误将不会重定向到我们使用 ErrorPage 参数指定的自定义错误页面.
So 404 error from WebLogic will not be redirected to our custom error page specified with ErrorPage parameter.
解决方法是创建一个简单的 Web 应用程序并将其部署到您的 WebLogic 上.在这个网络应用中:
The workaround is to create a simple webapp and deploy it onto your WebLogic. In this webapp:
在 [web.xml] 中指定您的自定义错误代码和页面映射,例如:
in [web.xml] Specifiy your custom error code and page mappings, e.g.:
<错误页面>
<error-code>404</error-code>
<location>/errors/404.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/errors/404.html</location>
</error-page>
在 [weblogic.xml] 中声明您的上下文根是/":
in [weblogic.xml] State that your context-root is '/':
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</weblogic-web-app>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<context-root>/</context-root>
</weblogic-web-app>
您需要有错误页面,例如在您的 web 应用程序的/errors"文件夹中.
Your need to have error pages in place such as in '/errors' folder of you webapp.
请注意,FMW 欢迎页面应用程序"可能已经部署并在您的 WebLogic 域中使用/"作为上下文根.如果是这种情况,我认为取消部署或取消目标是安全的,但建议您向产品支持部门提出 SR,询问这样做是否困难.
Note that the 'FMW Welcome Page Application' might have already been deployed and using '/' as context-root in your WebLogic domain. If that is the case, I believe it is safe to undeploy it or untarget it, but you are advised to raise a SR to product support asking whether it is hardful to do so.
这篇关于Apache-Weblogic 404 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!