tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Possible bug between Apache 2.4 and Tomcat 7 via AJP when POSTing
Date Wed, 31 May 2017 18:24:52 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Nic,

On 5/31/17 8:42 AM, Nicholas Cottrell wrote:
> Hi All!
> 
> I'm having a problem setting up an existing webapp from Apache
> 2.2/Tomcat6 on a new server running Centos 7, and the following
> packages:
> 
> httpd	2.4.6-45.el7.centos.4 tomcat.noarch
> 7.0.69-11.el7_3                 @updates tomcat-native.x86_64
> 1.1.34-1.el7                    @epel
> 
> For debugging I have enabled AJP/1.3 and 8009 and HTTP on 8080,
> then use Apache to ProxyPass.
> 
> With my initial configuration, data from a form POST is not
> available via request.getParameter:
> 
> ProxyPass / ajp://localhost:8009/ <ajp://localhost:8009/> retry=1
> acquire=3000 timeout=600 Keepalive=On ProxyPassReverse /
> ajp://localhost:8009/ <ajp://localhost:8009/>
> 
> But changing it to this fixes everything:
> 
> ProxyPass / http://localhost:8080/ <http://localhost:8080/> retry=1
> acquire=3000 timeout=600 Keepalive=On ProxyPassReverse /
> http://localhost:8080/ <http://localhost:8080/>
> 
> In the broken instance, request.getParameter("x") returned null,
> but request.getReader() returned bytes with "x=123" so seems that
> Apache is sending the POST body but Tomcat is not processing it
> correctly, yes?
> 
> Please also see
> https://stackoverflow.com/questions/44167876/problems-with-post-parame
ters-with-tomcat-ajp-on-apache-2-4-but-not-2-2
> <https://stackoverflow.com/questions/44167876/problems-with-post-param
eters-with-tomcat-ajp-on-apache-2-4-but-not-2-2>
> for my steps so far.
> 
> I would prefer to switch back to AJP for the proxy, since I
> understand it is more performant, right? Should I try forcing a
> Tomcat 8 install to see if the problem persists there too?

If you call request.getReader/getInputStream before any of the
request.getParameter family of methods, then all request.getParameter*
methods will return null. That's because Tomcat must consume the
request body in order to parse POST parameters. If you call
request.getReader/getInputStream, then Tomcat assumes that you will be
handling the request body (and any associated parameters therein).

Is it possible that you are "damaging" the request by inspecting the
request body?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJZLwp0AAoJEBzwKT+lPKRY+GkP/RRGHM9JZmBneogWEN1WEjJK
LhBlXJE1aQvKaP7Mpsj5q8VG+/pjWVfBSz8yBcLQPK4ty27LjPQF9fa1kTQZikrc
xpe5pJDo/Tp/xeztPLWf3l4fvBaH8/fjbb+U9XrA1+00rev1FmcI/E5Qz6qMpj70
P2g/eCWYVUaNGNjrSR4YGGFzjq3/e7uD+a1V/gdQ5XtQQZBwT8tY4BdWBqbXmKoS
MCvDzORr5QpD7Oy2OA9SCQ9/oMNe8ygmfKNlX+zMaasUhFfcXNP20iVor8YQLuLL
jHmABh0VyRwKwodOcpiXg28+7sdGaD5HQvqG1flTS9xK2OdzYNLVXuek2smq3KU4
1qXiUp8dz6V7H/CYjG8hWXgQnZnfdgHSyi/S0NiZucQ35v4IbhRjQzKaLGHduqyV
5GP5eToQ2OrSwdFYVoa73E8eQgiBmDrodDzc9Ocew/fOTVQ1rP8nsNYU77mjwr3k
Zh1m9RtG0Yi7RvBE9ifIm1p2woQQkD7ctIeaQvpUjJFfmexC3UFTFzwj9WLg0l46
rREx7BPkua9rxr+ttlSN/Dij26CPTVoy/RbM0naIBZYHBRNd4KFy85INdxYC79ug
ZZZrlQEozSEqtA7ooT5+fw25B9cudH+Dy5mfjqxtF2m8Ll0p3m+o1f53T0sEHV7m
hZTfhw0inWvHyEiece/v
=NL2s
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message