Bug 57259 - mod_proxy_ajp + apache 2.4 on windows not using TCP connection pool
Summary: mod_proxy_ajp + apache 2.4 on windows not using TCP connection pool
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_ajp (show other bugs)
Version: 2.4.10
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: FixedInTrunk
Depends on:
Reported: 2014-11-25 14:39 UTC by slaklu
Modified: 2015-01-09 20:39 UTC (History)
1 user (show)

trace8 log (78 bytes, text/plain)
2014-11-25 15:25 UTC, slaklu
httpd.conf (19.76 KB, text/plain)
2014-11-25 18:52 UTC, slaklu
Don't add default port (of any known scheme) to the name of proxy workers (1.63 KB, patch)
2014-12-09 12:08 UTC, Yann Ylavic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description slaklu 2014-11-25 14:39:33 UTC
1. Extract httpd-2.4.10-win64-VC11.zip from apachelounge or apachehaus
2. Extract tomcat (ie. apache-tomcat-7.0.57-windows-x64.zip)
3. Configure httpd:
   - enable mod_proxy
   - enable mod_proxy_ajp
   - configure connection to tomcat:
     ProxyPass / ajp://
     ProxyPassReverse / ajp:// 
4. Start tomcat.
5. Start httpd.
6. Open http://localhost/ by browser.
7. Observe number of TCP connections using: netstat -an when refreshing the page.

Each new connection from httpd to tomcat creates new TCP connection (ie.> All of them have TIME_WAIT status and are destroyed by OS after 4 minutes (default value of TcpTimedWaitDelay on windows). In extreme, number of TCP connection will exceed windows limit (by default it's ~14K). I confirmed that by sending lots of request to apache one by one.

I have check the same scenario using apache 2.2 on windows, and apache 2.4 on linux. It works it different way. Httpd creates few
connections to tomcat and reuse them. They have ESTABLISHED status.

Occurs on Windows 7 64bit, Windows Server 2008 R2 64bit.
Comment 1 Eric Covener 2014-11-25 14:41:02 UTC
Comment 2 slaklu 2014-11-25 15:25:19 UTC
Created attachment 32227 [details]
trace8 log

trace8 log file url attached.

The log contains:
- service startup
- opening http://localhost/ by browser (9 connections was created)
- pause
- page refresh (F5), (9 new connections created)
- shutdown
Comment 3 Eric Covener 2014-11-25 15:32:13 UTC
It seems like your proxy is hitting the "default worker" which is not reusable. It is kind of an internal concept to mod_proxy that bleeds out when you use anything more than the most basic ProxyPass (e.g. rewriterule [P])

[Tue Nov 25 16:22:49.359276 2014] [proxy:trace2] [pid 3336:tid 504] proxy_util.c(1937): [client ::1:51140] *: found reverse proxy worker for ajp://


Are you sure the failing ones are mapped just by ProxyPass?
Comment 4 slaklu 2014-11-25 18:52:44 UTC
Created attachment 32228 [details]

My problem came up with a more complicated configuration, but as you can see is also present when using almost default one.

I have attached my httpd.conf to not have doubts.

For comparison, I used httpd-2.2.29-win64.zip from apachelounge. Same configuration but no problem.
Comment 5 slaklu 2014-12-09 07:05:58 UTC
Do you need any additional information, or we can treat this problem as a bug?
Comment 6 Yann Ylavic 2014-12-09 12:08:06 UTC
Created attachment 32277 [details]
Don't add default port (of any known scheme) to the name of proxy workers

Since 8089 is default port for the AJP scheme, the canonicalization removes it from the URL, but the proxy worker name (URL) still contains it.

Hence the failure to match the requested URL with the worker, and the use of the default worker (reverse proxy).

Can you please try the attached patch?

A workaround would be to not specify the port 8009 in the ProxyPass declaration:
  ProxyPass / ajp://
  ProxyPass / ajp://[::1]/
Comment 7 Mario 2014-12-10 09:00:09 UTC
Not adding a standard port or adding a not-standard port works.
Comment 8 Yann Ylavic 2014-12-10 09:18:38 UTC
(In reply to Mario from comment #7)
> Not adding a standard port or adding a not-standard port works.

With (or without) the patch applied?

(please don't change the status if you are are not the OP, it might work for you with the patch applied but nothing is commited in httpd yet).
Comment 9 slaklu 2014-12-10 09:23:22 UTC
Workaround works also for me (without default port of with not-standard).

It will be hard to verify the patch for me, since this requires compiling apache on windows. I'll ask apachelounge for support.
Comment 10 Yann Ylavic 2014-12-10 18:49:22 UTC
Proposed for backport in r1644506.
Comment 11 Christophe JAILLET 2015-01-09 20:39:09 UTC
Backported in 2.4.x in r1650655

Will be part of 2.4.11