【发布时间】:2017-10-25 08:36:15
【问题描述】:
我正在运行 Apache 2.4 和 Tomcat 7 的新机器上设置我们的 webapp 版本,但无法登录。当前站点在 Apache 2.2 和 Tomcat 6 上运行。
调试显示 request.getParameter() 仅在 2.4 站点上返回 null。
我已经在所有浏览器中检查了这一点,并且可以在网站上导航,因此 AJP 至少可以部分正常工作 - 只有当我发布表单时,我的 Tomcat 看不到表单数据。
两者的配置相同:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAlias cdn.example.com
ServerAlias prod.example.com
ProxyPreserveHost On
ProxyPass /images/ !
ProxyPass /font/ !
ProxyPass /style/ !
ProxyPass / ajp://localhost:8009/ retry=1 acquire=3000 timeout=600 Keepalive=On
ProxyPassReverse / ajp://localhost:8009/
server.xml 中定义的连接器为:
<Connector port="8009" address="localhost"
maxThreads="250" minSpareThreads="5" maxSpareThreads="15"
connectionTimeout="200000"
packetSize="16384"
maxHttpHeaderSize="16384"
enableLookups="false" redirectPort="8443"
emptySessionPath="true" URIEncoding="UTF-8" protocol="AJP/1.3"/>
浏览器请求头是:
Host: prod.example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es,sv;q=0.9,de;q=0.8,en;q=0.6,es-MX;q=0.5,en-AU;q=0.4,ja;q=0.3,fr;q=0.1
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Content-Length: 73
Referer: http://prod.example.com/en_US/auth/login.action
Cookie: JSESSIONID=07FB9E1A02A4464C0D65B332B53EF02F
Connection: keep-alive
Upgrade-Insecure-Requests: 1
我启用了通过端口 8080 直接访问 Tomcat,并且通过这种方式登录也可以正常工作。
代码来自同一个 git 存储库和分支,因此其他所有内容都应与旧站点相同。我应该研究 Tomcat 7 或 Apache 2.4 的变化来跟踪这个吗?
更新:我创建了一个非常简单的 test.jsp,并设置了一个要发布的表单。我用...
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String name = (String) paramNames.nextElement();
String[] values = request.getParameterValues(name);
.. 转储参数。通过直接 8080 URL,这可以完美地工作,但是通过 Apache/AJP,所有 POST 参数都会被忽略,但是如果我手动将 GET 参数添加到 URL,例如。 ?test=123 这些工作正常。
更新 2:我将request.getReader() 的输出添加到我的test.jsp,并且我的 POST 数据在那里正确显示,例如t1=Some+text&t2=Testing 但 request.getParameter("t1") 仍然是 null。我一定错过了一些非常愚蠢的东西。
更新 3:我最初认为这是与 SSL 相关的,但现在设置了一个非 SSL 虚拟主机,这也有完全相同的问题。我的测试页有一个日期戳,所以它似乎不是缓存问题。
更新 4:我刚刚做了以下更改,允许正确处理表单 POST 数据:
# ProxyPass / ajp://localhost:8009/ retry=1 acquire=3000 timeout=600 Keepalive=On
# ProxyPassReverse / ajp://localhost:8009/
ProxyPass / http://localhost:8080/ retry=1 acquire=3000 timeout=600 Keepalive=On
ProxyPassReverse / http://localhost:8080/
那么,这看起来像 Apache 或 Tomcat 错误吗?
【问题讨论】:
标签: apache tomcat7 apache2.4 ajp