我设立一个版本,我们的Web应用程序的运行Apache 2.4和Tomcat 7新机上,并不能获得登录工作的Tomcat/AJP在Apache 2.4(而不是2.2)。当前站点运行在Apache 2.2和Tomcat 6上。问题与POST参数与
调试显示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,并且登录也可以以这种方式正常工作。
的代码是从同一个混帐回购协议和分支来了,所以一切应该是等同于传统的网站。我应该看看Tomcat 7还是Apache 2.4的变化来跟踪这个?
更新:我创建了一个非常简单的test.jsp,并将表单设置为发布。我用...
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String name = (String) paramNames.nextElement();
String[] values = request.getParameterValues(name);
..转储参数。通过直接URL 8080这个作品完美,但通过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的VirtualHost,这有完全相同的问题。我的测试页有一个日期戳记,所以它看起来不是缓存问题。
更新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的错误?
这甚至适用于微小的数据包 - 只有几个字符的输入文本的形式。它看起来像是Tomcat在通过AJP进入时不能正确处理表单数据 - 但是仍然可以通过request.getReader获得字节。 –
出于性能考虑,希望将ProxyPass与AJP(通过HTTP)结合使用。 –