You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins 2.475+搭配Tomcat10.x启用反向代理时如何允许编码斜杠?

解决Tomcat 10.x中允许编码斜杠的问题

问题背景

将Jenkins从2.474升级到2.475后,因该版本要求Servlet容器实现Servlet 6.0 API,遂将Tomcat升级至10.1版本,检查反向代理时出现以下错误:

Invalid URI: [The encoded slash character is not allowed]
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

Tomcat 9.x及更早版本中,可通过在tomcat/conf/catalina.properties中添加org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true解决,但该特性在Tomcat 9.0中被弃用,Tomcat 10.0中已移除,官方说明如下:

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH
Use of this system property is deprecated. It will be removed from Tomcat 10 onwards.
If this system property is set to true, the default for the encodedSolidusHandling attribute of all Connectors will be changed from reject to decode. If decoded, it will be treated a path delimiter.

解决方法

Tomcat 10.x需通过配置Connector的encodedSolidusHandling属性实现需求,步骤如下:

  1. 打开Tomcat的conf/server.xml配置文件
  2. 找到对应Connector节点(例如默认HTTP/1.1的8080端口Connector)
  3. 添加encodedSolidusHandling="decode"属性,示例配置:
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
           encodedSolidusHandling="decode" />
  1. 保存文件后重启Tomcat服务

参数说明

encodedSolidusHandling支持三个可选值:

  • reject:拒绝包含编码斜杠的请求(默认行为)
  • decode:解码编码斜杠并将其作为路径分隔符处理(与旧版本ALLOW_ENCODED_SLASH=true效果一致)
  • passThrough:保留编码斜杠,不进行解码处理

内容的提问来源于stack exchange,提问作者Autumn Skye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 21:18:20