tomcat8.0.30升级为8.5.51注意事项

最近由于爆发了Apache Tomcat AJP协议任意文件下载和任意文件包含可导致远程命令执行的漏洞,tomcat8系列的需要升级至8.5.51.
升级注意几个问题:

  1. bin/catalina.sh
    我们是通过在执行环境配置env来区别不同环境的,所以需要在bin/catalina.sh中添加-Denv=prod代表正式环境。另外性能优化相关的都在这个文件中配置。从原8.0.30复制过来
  2. conf/server.xml
    在这个文件中配置端口号,这个端口号和原来的一致(nginx转发),所以启动前要先关闭原tomcat
  3. conf/context.xml
    启动的时候有警告,在conf/context.xml中配置 <Resources cachingAllowed="true" cacheMaxSize="150000" ></Resources>

[localhost-startStop-1] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/js/ueditor/third-party/highcharts/highcharts.src.js] to the cache for web application [/dgshop-0.0.1-release] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache

  1. conf/catalina.properties
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:467)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)


由于高版本的tomcat的限制(Tomcat在 7.0.73, 8.0.39, 8.5.7 版本后,在http解析时做了严格限制),可以通过在conf/catalina.properties中添加两行和conf/server.xml添加两行配置解决

conf/catalina.properties,requestTargetAllow只能最多配置|{},如果要放开更多的字符需要在conf/server.xml中的Connector添加属性。

tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

conf/server.xml添加需要放开的字符

relaxedPathChars="|{}[],&quot;^\"
relaxedQueryChars="|{}[],&quot;^\"

参考

终极解决方案: Invalid character found in the request target. The valid characters are defined in RFC 3986

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值