The goal of this resource is to represent a working configuration of the above mentioned servers. We here assume you have installed apache prefork, mod_jk и jboss.
We start with the configuration of the apache http server:
apache2.conf :
# Replace jsp-hostname with the hostname of your JSP server, as
# specified in workers.properties.
#
<IfModule mod_jk.c>
JkWorkersFile /etc/apache2/includes/workers.properties
JkShmFile /var/log/apache2/jk-runtime-status
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
</IfModule>
<IfModule mpm_prefork_module>
StartServers 10
MinSpareServers 10
MaxSpareServers 30
MaxClients 200
MaxRequestsPerChild 0
</IfModule>
#Your site config
<VirtualHost 78.78.78.78:80>
ServerAdmin info@yoursite.com
ServerName www.yoursite.com
ServerAlias yoursite.com 78.78.78.78
ErrorLog /var/log/apache2/users/some_error.log
<IfModule mod_jk.c>
JkMount /*.* worker1
JkMount /* worker1
</IfModule>
</VirtualHost>
JkWorkersFile must point to
workers.propertiesHere is the file workers.properties
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=8009
worker.worker1.lbfactor=1
worker.worker1.connection_pool_timeout=600
#Socket timeout in seconds used for the communication channel between JK and remote host.
worker.worker1.socket_timeout=40
worker.worker1.socket_keepalive=1
#Do not use connection_pool_size with values higher then 1 on Apache 2.x prefork
worker.worker1.connection_pool_size=1
#Do not use connection_pool_size with values higher then 1 on Apache 2.x prefork
worker.worker1.connection_pool_minsize=1
worker.worker1.ping_mode=A
#Timeout in milliseconds used when waiting for the CPong answer of a CPing connection probe.
worker.worker1.ping_timeout=10000
#connection_ping_interval in seconds
worker.worker1.connection_ping_interval=70
server.xml in the JBoss or Tomcat:
<Connector port="8009" address="${jboss.bind.address}"
protocol="AJP/1.3"
emptySessionPath="true"
enableLookups="false"
redirectPort="8443"
URIEncoding="UTF-8"
maxThreads="400"
connectionTimeout="600000"
acceptCount="400"
/>
The key here is:
- when determining the
MaxClients you must honor this formula:
MaxClients = maxThreads * 0.8
or at least
MaxClients to be not more than
maxThreads, considering
MaxClients cannot be more 256
-
connection_pool_timeout=600 must be as
<Connector...connectionTimeout="600000", having connection_pool_timeout is in seconds and connectionTimeout is in milliseconds.
One important remark here is how mod_jk forwards the request.
In the mod_jk configuration we used
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
and this is not very correct and more specifically the option
+ForwardURICompat. If we don't use
mod_rewrite it is more correct to pass URI path without any change to JBOSS.
+ForwardURICompatUnparsed option is most secure, because it does not modify the URI. It is more safe option in case we have UTF symbol in the url. If we have URL PARAMETERS which are utf it may work with the
+ForwardURICompat , but if you have utf symbols in the PATH, for example:
/some/%D0%B2%D0%B0%D0%B3%D0%BE%D0%BD?param1=value1
then the thing that works is this:
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories