如何在 Azure PaaS 上的 Tomcat 中扩展 ErrorReportValve? [英] How to extend ErrorReportValve in Tomcat on Azure PaaS?

查看:47
本文介绍了如何在 Azure PaaS 上的 Tomcat 中扩展 ErrorReportValve?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Tomcat 上实现自定义错误页面,在 Azure 的 PaaS 上运行.

将以下内容添加到 META-INF/context.xml,按照

理想情况下,我想尝试扩展自定义 ErrorReportValve.

以下说明如何在Tomcat中设置自定义ErrorReportValve如何在Tomcat中设置自定义ErrorReportValve?.或者在 tomcat8 - 400 的自定义错误页面

有没有什么办法可以在Azure上的PaaS上运行的Tomcat中实现这个解决方案,在那里无法访问server.xml,但是有META-INF/context.xml?

例如放

context.xml中?

解决方案

我设法通过在应用服务的高级工具中使用 SSH 从/usr/local/tomcat/conf 复制 server.xml 并使用它来使其工作配置在里面.

然后我将新的 server.xml 放在 {home}/tomcat/conf 文件夹中并重新启动应用程序.

I am attempting to implement custom error pages on Tomcat, running on PaaS in Azure.

Adding the following to META-INF/context.xml, as per Which is the best way to mask / hide tomcat version from error pages?

<Valve className="org.apache.catalina.valves.ErrorReportValve"
    showReport="false" 
    showServerInfo="false"/> 

will show a bare-bones error page, which does hide exceptions etc. from the user but is neither pretty, nor does it send the actual error message to the log.

So ideally, I would like to try extending the custom ErrorReportValve.

The following gives instructions how to set a custom ErrorReportValve in Tomcat How to set a custom ErrorReportValve in Tomcat?. Or see @martinnemec3's answer in tomcat8 - custom error page for 400

Is there any way of implementing this solution in Tomcat running on PaaS on Azure, where there is no access to server.xml, but there is META-INF/context.xml?

For instance, putting

<Host errorReportValveClass="org.valves.CustomErrorReportValve"  />

in the context.xml?

解决方案

I managed to make it work by copying the server.xml from /usr/local/tomcat/conf using SSH in the advanced tools of app service and using this config in it.

<Valve className="org.apache.catalina.valves.ErrorReportValve"
    showReport="false" 
    showServerInfo="false"/> 

then I placed the new server.xml in {home}/tomcat/conf folder and restarted the application.

这篇关于如何在 Azure PaaS 上的 Tomcat 中扩展 ErrorReportValve?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆