IIS ARR:从转发的请求中禁用或覆盖附加的“ X-Original-URL” HTTP标头

问题描述 投票:0回答:1

[当IIS将大型搜索请求URL(通过ARR URL重写)转发到在Tomcat上运行的搜索API(后端为Solr)时,我们遇到问题,而Tomcat立即拒绝该请求,并出现400-错误请求错误。

完整的Tomcat响应:

HTTP / 1.1 400错误的请求伺服器:Apache-Coyote / 1.1日期:2019年9月12日星期四00:17:39 GMT内容长度:0连接:关闭

URL的大小/长度不是问题,这是因为IIS在将请求转发给Tomcat时,在X-Original-URL标头中包含了原始URL,甚至不是该标头中URL的长度,但X-Original-URL标头中查询字符串参数之一的部分内容导致Tomcat拒绝请求。

我尝试将maxHttpHeaderSize属性添加到Tomcat的配置XML中的连接器中,如下所示:

]

但是增加最大标头大小没有效果。

我已经验证了IIS / ARR尚未对X-Original-URL头中的X / Original-URL标头进行解码/重新编码(或通过其他方式修改了URL),方法是通过Fiddler代理它们并检查转发的请求来捕获来自IIS的请求。

通过IIS转发的请求通过Fiddler代理后,我可以从请求中删除X-Original-URL(通过自定义的Fiddler规则脚本),然后Tomcat接受请求并对其进行处理,并且响应不通过IIS而通过IIS转发回去问题。

我们设法将查询字符串参数的内容(“ fq”指定对Solr中索引的“ path”构面字段进行搜索)作为可能的罪魁祸首,因为如果我们将该参数中的路径值缩短了删除路径的最后一部分,则请求不会被拒绝。不幸的是,修整路径不是一种选择,因为它被用作搜索查询的一部分,以便返回包含在特定路径中的搜索结果。

以下是引起400错误(当作为X-Original-URL标头的一部分包含时)的路径值的示例(长度令人抱歉):

FQ =路径%3A(%22%5C%22TestOTIF%5C%22%5C-H4sIAAAAAAAAAKtWKlGyMtJRSlayUnIvyi8tUAhJTc7Iy8%5C%2FJT69U0lEqVrKKrlbKA0qGpBaX%5C%2BId4ugEFS5G5tbG1AATZhNNEAAAA%3B%5C%22Documents%5C%22%5C-H4sIAAAAAAAAAKtWKlGyMtJRSlayUnIvyi8tUAhJTc7Iy8%5C%2FJT69U0lEqVrKKrlbKA0qGpBaX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%2B33s83owAuiaQoDhMLr4qoeRonXHDGwQe9DrD5lAoH1px3GcZ%5C%2FzHdCAzoUto5GZ%5C%2FKBv9tXcZ%5C%2BUvfqpxPBo0w2Ufs%5C%2Bq4WYi1ZqU%5C%2FikVNB28EVw1tWbelVvO85aXnRzzh%5C%2FSB6kO1JTIAAAA%3B%5C%22Revised + FEED +相位+ 2 +文档+和+附加+文档+%5C- +未+至+打印%5C%22%5C-H4sIAAAAAAAAAE2PwQrCMAyGXyXkPMF5UOh1VhGUDd1NREpbt8JMZW0FGXt3O5TqLd%5C%2BXn%5C%2FxkQI9skaFEhtvehgfUWrZkO9u8MEOH7DwgxWWtnS%5C%2Fr3SbK8I%5C%2FjJcMO2Se0tjLcNXn3TZ1a0WsFPz1meEsn98E4EdWHChtImi7xQWtvqHFJ8OKaL%5C%2FN5vrryouRJ76s0HvXTuNi34XwNVSuchsVU7kCQAqGU8caS6EBNbgZkPXgLj96Qj4%5C%2BMb0LvykANAQAA%3B%5C%22Control +系统+和+仪表%5C%22%5C-H4sIAAAAAAAAAE2PQWvDMAyF%5C%2F4rQOYWlhw5yTd1R6GhpcxujmNhrDK5cLHlQSv77nGV4vel9kp70H ijYLCvsscG3GNINOtsPFHy43LFCxubjgZSbnWXZd9tNhulZjp8VemzmoXXo09WS8N%5C%2FUadDRGvjHY4VfxXKXHOuMZtWGRL3zRb9bK44uXIBqz%5C%2FWqfqlfz6rdq4J3h1Ie7bfjfG%5C%2Bj1BoOg2YLy%5C%2Bk4gyYD2hgnLpD2YCa2AAoCEuAWHcnTHyQxeDjdWex1Xt0SS%5C%2FyNoCeHHHr8AUaYBdM5AQAA%3B%5C%22Cause +和+效应+框图%5C%22%5C-H4sIAAAAAAAAAE2QwWrDMBBEf2XZswt1Din4aislkJLQ%5C%2BFZKELJsC%5C%2BRVkFaFEPzvleui5KZ5O5pZ6Y6M1aZAhRW%图5C%2Bexev0Go1krNuuGGBAauvO1Iatjrwsd3vEozPcv4u0GK1mhqn4qSJw7%5C%2FrPEqvO3jgucA%5C%2BRx6iCTKhVdUukjI26w%5C%2Bt2dAQMhD1pdyWr%5C%2BXbRdRHkfHhlI%5C%2BF%5C%2BseE1LcTooHTKIOGzVIeQFIHsusMG0fSQrewFyDHwA6u3hA%5C%2F7UHsnYXzLbCe1qt7Cuz%5C%2FniCXhIdXxtSxOETfa8XQGDl4OaVfmX8BphIoiFoBAAA%3D%22)

上面编码的查询字符串值包含正斜杠,转义引号(如\“,但编码为%5C%22),唯一的路径文件夹ID和其他内容。

以上解码:

fq=path:("\"TestOTIF\"\-H4sIAAAAAAAAAKtWKlGyMtJRSlayUnIvyi8tUAhJTc7Iy8\/JT69U0lEqVrKKrlbKA0qGpBaX\+Id4ugEFS5G5tbG1AATZhNNEAAAA;\"Documents\"\-H4sIAAAAAAAAAKtWKlGyMtJRSlayUnIvyi8tUAhJTc7Iy8\/JT69U0lEqVrKKrlbKA0qGpBaX\+Id4ugEFS5G5tbE6SjlKVhBFLvnJpbmpeSXFUFXBGYlFqSkKCOHaWgCTIarwcQAAAA==;\"Luisa\"\-H4sIAAAAAAAAAKtWKlGyMtJRSlayUnIvyi8tUAhJTc7Iy8\/JT69U0lEqVrKKrlbKA0qGpBaX\+Id4ugEFS5G5tbE6SjlKVhBFLvnJpbmpeSXFUFXBGYlFqSkKCOFaHaU0uJE\+pZnFiUADagGOHHHLhQAAAA==;\"Council\"\-H4sIAAAAAAAAAKtWKlGyMtJRSlayUnIvyi8tUAhJTc7Iy8\/JT69U0lEqVrKKrlbKA0qGpBaX\+Id4ugEFS5G5tbE6SjlKVhBFLvnJpbmpeSXFUFXBGYlFqSkKCOFaHaU0uJE\+pZnFiUAhCM85vzQvOTMHaGAtADfvIOmVAAAA;\"Meetings\"\-H4sIAAAAAAAAAE2MvQrCMBRGX6V8c6aOWRWLoDiYTTqUeG0D8V5pcgcpeXcDlep4zvezIMO2Bh4W3Sz6ahz5iSXK\+IZBgr0t4Bo6Svnijocq9R9LbxBh19JevD6Jc\/q2rt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gnLpD2YCa2AAoCEuAWHcnTHyQxeDjdWex1Xt0SS\/yNoCeHHHr8AUaYBdM5AQAA;\"Cause+and+Effect+Diagram\"\-H4sIAAAAAAAAAE2QwWrDMBBEf2XZswt1Din4aislkJLQ\+FZKELJsC\+RVkFaFEPzvleui5KZ5O5pZ6Y6M1aZAhRW\+exev0Go1krNuuGGBAauvO1Iatjrwsd3vEozPcv4u0GK1mhqn4qSJw7\/rPEqvO3jgucA\+Rx6iCTKhVdUukjI26w\+t2dAQMhD1pdyWr\+XbRdRHkfHhlI\+f\+seE1LcTooHTKIOGzVIeQFIHsusMG0fSQrewFyDHwA6u3hA\/7UHsnYXzLbCe1qt7Cuz\/niCXhIdXxtSxOETfa8XQGDl4OaVfmX8BphIoiFoBAAA=")

我的问题是:

  1. 当上面的任何编码信息作为值包含在HTTP标头中,或更具体地说,当包含在X-Original-URL标头中时,Tomcat是否会由于某种原因(长度超出)而拒绝Tomcat?

  2. 我已经尝试在IIS URL重写中重写HTTP_X_ORIGINAL_URL服务器变量,但是它不起作用,因为IIS在处理了重写规则之后会附加该标头。还有其他方法可能会禁止在IIS或ARR中包含该特定标头吗?还是至少能够覆盖/重写该标头中的值?

  3. 对于Tomcat,我已经检查了所有可能与请求和/或标头大小/长度有关的可能的配置设置,没有发现超出“ maxHttpHeaderSize”的内容可能对防止请求拒绝有任何影响。是否可以更改其他设置以允许Tomcat接受请求?

很抱歉,这里的帖子很长! :)

非常感谢您提供有关此问题的任何其他信息或建议,或可能的解决方案!谢谢!

tomcat iis http-headers url-rewrite-module arr
1个回答
0
投票

感谢您的答复!

© www.soinside.com 2019 - 2024. All rights reserved.