このコンテンツは選択した言語では利用できません。
HTTP Connectors and Load Balancing Guide
HTTP load balancing for Red Hat JBoss Web Server
Abstract
Chapter 1. Introduction リンクのコピーリンクがクリップボードにコピーされました!
- The Apache Tomcat Connector (mod_jk) supports the load balancing of HTTP calls to a set of Servlet containers while maintaining sticky sessions, and communicates over AJP.
- mod_cluster is a more advanced load balancer than mod_jk, and provides all of the functionality of mod_jk, plus other additional features. These include real-time load balancing calculations, application life-cycle control, automatic proxy discovery, and multiple protocol support.
Important
Chapter 2. Apache Tomcat Connector (mod_jk) リンクのコピーリンクがクリップボードにコピーされました!
2.1. Overview リンクのコピーリンクがクリップボードにコピーされました!
2.1.1. Download and Install リンクのコピーリンクがクリップボードにコピーされました!
mod_jk is included in the native installation binaries for JBoss Enterprise Application Platform (JBoss EAP) and JBoss Web Server.
2.2. Configure Load Balancing Using Apache HTTP Server and mod_jk リンクのコピーリンクがクリップボードにコピーされました!
JWS_HOME/httpd/conf.d/. The sample configuration files are: mod_jk.conf.sample, workers.properties.sample, and uriworkermap.properties.sample. To use these samples instead of creating your own configuration files, remove the .sample extension, and modify their content as needed.
Note
2.4.x as the Apache version, and select Tomcat as the back end configuration.
2.2.1. Configuring Apache HTTP Server to Load mod_jk リンクのコピーリンクがクリップボードにコピーされました!
Procedure 2.1. Configure Apache HTTP Server to Load mod_jk
- Open
JWS_HOME/httpd/conf/httpd.confand add the following lines at the end of the file:Include mod_jk's specific configuration file
# Include mod_jk's specific configuration file Include conf.d/mod_jk.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a new file:
JWS_HOME/httpd/conf.d/mod_jk.conf - Add the following configuration to the
mod_jk.conffile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Important
TheLoadModuledirective must reference the mod_jk library directory location for the native binary you installed.Note
TheJkMountdirective specifies which URLs Apache HTTP Server will forward to the mod_jk module. Based on the directive's configuration, mod_jk forwards the received URL onto the correct Servlet containers.To enable Apache HTTP Server to serve static content (or PHP content) directly, and only use the load balancer for Java applications, the suggested configuration above specifies that all requests with the URL/application/*are sent to the mod_jk load-balancer.Alternatively, you can forward all URLs to mod_jk by specifying/*in the directive. Optional: JKMountFile Directive
In addition to theJkMountdirective, you can use theJkMountFiledirective to specify a mount point's configuration file. The configuration file contains multiple Tomcat forwarding URL mappings.- Navigate to
JWS_HOME/httpd/conf.d/. - Create a file named
uriworkermap.properties. - Using the following syntax example as a guide, specify the URL to forward and the worker name.The syntax required takes the form:
/URL=WORKER_NAMEThe example block below configures mod_jk to forward requests to/jmx-consoleand/web-consoleto Apache HTTP Server.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In
JWS_HOME/httpd/conf.d/mod_jk.conf, append the following directive:Use external file for mount points. It will be checked for updates each 60 seconds. The format of the file is: /url=worker /examples/*=loadbalancer
# Use external file for mount points. # It will be checked for updates each 60 seconds. # The format of the file is: /url=worker # /examples/*=loadbalancer JkMountFile conf.d/uriworkermap.propertiesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Optional: Configure Apache HTTP Server Logging
You can configure the Apache HTTP Server that is doing the load balancing to log which worker node handled a request. This may be useful when troubleshooting your load balancer.To enable this for mod_jk, you can either:- include
%win yourJkRequestLogFormat; or - log the name of the mod_jk worker used by including
%{JK_WORKER_NAME}nin your Apache HTTP ServerLogFormat(s).
For more information onJkRequestLogFormat, see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html. For more information on Apache HTTP Server logging (including log rotation), see http://httpd.apache.org/docs/2.4/logs.html.
2.2.2. Configuring Worker Nodes in mod_jk リンクのコピーリンクがクリップボードにコピーされました!
2.2.2.1. Configuring Worker Nodes in mod_jk リンクのコピーリンクがクリップボードにコピーされました!
Procedure 2.2. Configure mod_jk Worker Nodes
- Understand the format of the
workers.propertiesdirectives, as specified in Section A.2, “workers.properties”. - Configure mod_jk. See Section 2.2.1, “Configuring Apache HTTP Server to Load mod_jk”.
- Navigate to
JWS_HOME/httpd/conf.d/, and create a file namedworkers.properties. - Add the following configuration into
workers.properties.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.3. Configuring Apache Tomcat to Work with mod_jk リンクのコピーリンクがクリップボードにコピーされました!
JWS_HOME/tomcat<VERSION>/conf/server.xml file, which contains the following configuration for this purpose:
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
jvmRoute attribute for your engine:
<Engine name="Catalina" jvmRoute="node1" >
<Engine name="Catalina" jvmRoute="node1" >
jvmRoute attribute value must match the worker name set in workers.properties.
Chapter 3. mod_cluster Connector リンクのコピーリンクがクリップボードにコピーされました!
3.1. Overview リンクのコピーリンクがクリップボードにコピーされました!
3.1.1. Key Features リンクのコピーリンクがクリップボードにコピーされました!
- The mod_cluster Management Protocol (MCMP) is an additional connection between the Tomcat servers and the Apache HTTP Server with the mod_cluster module enabled. It is used by the Tomcat servers to transmit server-side load figures and lifecycle events back to the Apache HTTP Server via a custom set of HTTP methods.
- Dynamic configuration of Apache HTTP Server with mod_cluster allows Tomcat servers that have mod_cluster listeners to join the load balancing arrangement without manual configuration.
- Tomcat servers performs the load calculations, rather than relying on the Apache HTTP Server with mod_cluster. This makes load balancing metrics more accurate than other connectors.
- The mod_cluster connector gives fine-grained application lifecycle control. Each Tomcat server forwards web application context lifecycle events to the Apache HTTP Server, informing it to start or stop routing requests for a given context. This prevents end users from seeing HTTP errors due to unavailable resources.
- AJP, HTTP or HTTPS transports can be used.
3.1.2. Components リンクのコピーリンクがクリップボードにコピーされました!
| Component | Description |
|---|---|
mod_cluster_slotmem.so | The Shared Memory Manager module shares real time worker node information with multiple Apache HTTP Server processes. |
mod_manager.so |
The Cluster Manager module receives and acknowledges messages from nodes, including worker node registrations, worker node load data, and worker node application life cycle events.
|
mod_proxy_cluster.so | The Proxy Balancer Module handles request routing to cluster nodes. The Proxy Balancer selects the appropriate destination node based on application location in the cluster, current state of each of the cluster nodes, and the Session ID (if a request is part of an established session). |
mod_advertise.so |
The Proxy Advertisement Module broadcasts the existence of the proxy server via UDP multicast messages. The server advertisement messages contain the IP address and port number where the proxy is listening for responses from nodes that want to join the load-balancing cluster.
|
3.1.3. Limitations リンクのコピーリンクがクリップボードにコピーされました!
- Maximum Alias length: 100 characters (Alias corresponds to the network name of the respective virtual host; the name is defined in the Host element)
- Maximum context length: 40 characters (for example, if
myapp.waris deployed in/myapp, then/myappis the context) - Maximum balancer name length: 40 characters (the balancer property in mbean)
- Maximum JVMRoute string length: 80 characters (JVMRoute in the <Engine> element)
- Maximum domain name length: 20 characters (the domain property in mbean)
- Maximum hostname length for a node: 64 characters (hostname address in the <Connector> element)
- Maximum port length for a node: 7 characters (8009 is 4 characters, the port property in the <Connector> element)
- Maximum scheme length for a node: 6 characters (possible values are
http,https,ajp, the protocol of the connector) - Maximum cookie name length: 30 characters (the header cookie name for session ID default value:
JSESSIONIDfromorg.apache.catalina.Globals.SESSION_COOKIE_NAME) - Maximum path name length: 30 characters (the parameter name for the session ID default value:
JSESSIONIDfromorg.apache.catalina.Globals.SESSION_PARAMETER_NAME) - Maximum length of a session ID: 120 characters (session ID resembles the following:
BE81FAA969BF64C8EC2B6600457EAAAA.node01)
3.2. Configure Load Balancing Using Apache HTTP Server and mod_cluster リンクのコピーリンクがクリップボードにコピーされました!
Note
2.4.x as the Apache version, and select Tomcat as the back end configuration.
3.2.1. Configure a Basic Proxy Server リンクのコピーリンクがクリップボードにコピーされました!
3.2.1.1. Basic Proxy Configuration Overview リンクのコピーリンクがクリップボードにコピーされました!
- Configure a Proxy Server listener to receive worker node connection requests and worker node feedback.
- Optional: Disable server advertisement.
The proxy server advertises itself using UDP multicast. When UDP multicast is available between the proxy server and the worker nodes, Server Advertisement adds worker nodes without further configuration required on the proxy server, and minimal configuration on the worker nodes.
3.2.1.2. Configure a Load-balancing Proxy Using mod_cluster リンクのコピーリンクがクリップボードにコピーされました!
- Install JBoss Web Server, and configure the mod_cluster modules for your installation. See the JBoss Web Server Installation Guide for details.
Procedure 3.1. Configure a Load-balancing Proxy Using mod_cluster
Create a Listen Directive for the Proxy Server
Edit your mod_cluster configuration file (usuallyJWS_HOME/httpd/conf.d/mod_cluster.conf), and add the following:Listen IP_ADDRESS:PORT_NUMBER
Listen IP_ADDRESS:PORT_NUMBERCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where IP_ADDRESS is the address of the server network interface to communicate with the worker nodes, and PORT_NUMBER is the port on that interface to listen on.Note
The port must be open for incoming TCP connections.Example 3.1. Example Listen Directive
Listen 10.33.144.3:6666
Listen 10.33.144.3:6666Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Virtual Host
Add the following to your mod_cluster configuration file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where IP_ADDRESS and PORT_NUMBER are the values from the Listen directive.Optional: Disable Server Advertisement
TheAdvertiseFrequencydirective makes the server to periodically send server advertisement messages via UDP multicast. By default, this occurs every 5 seconds.These server advertisement messages contain the IP_ADDRESS and PORT_NUMBER specified in the VirtualHost definition. Worker nodes configured to respond to server advertisements use this information to register themselves with the proxy server.To disable server advertisement, add the following directive to theVirtualHostdefinition:ServerAdvertise Off
ServerAdvertise OffCopy to Clipboard Copied! Toggle word wrap Toggle overflow If server advertisements are disabled, or UDP multicast is not available on the network between the proxy server and the worker nodes, configure worker nodes with a static list of proxy servers. See Section 3.2.2.2, “Configuring a Worker Node with a Static Proxy List”.Optional: Configure Apache HTTP Server Logging
You can configure the Apache HTTP Server that is doing the load balancing to log which worker node handled a request. This may be useful when troubleshooting your load balancer.To enable this for mod_cluster, you can add the following to your Apache HTTP ServerLogFormatdirective(s):- %{BALANCER_NAME}e
- The name of the balancer that served the request.
- %{BALANCER_WORKER_NAME}e
- The name of the worker node that served the request.
For more information on Apache HTTP Server logging (including log rotation), see http://httpd.apache.org/docs/2.4/logs.html.Stop and Start the JBoss Web Server Apache Service
See the JBoss Web Server Installation Guide for detailed instructions.
3.2.2. Configuring Worker Nodes リンクのコピーリンクがクリップボードにコピーされました!
3.2.2.1. Configuring a Tomcat Worker Node リンクのコピーリンクがクリップボードにコピーされました!
Note
Supported Worker Node types
- Red Hat JBoss Web Server Tomcat service
mod_cluster JBoss Web Server Node Limitations
- Non-clustered mode only.
- Only one load metric can be used at a time when calculating the load balance factor.
- Install a supported JBoss Web Server.
- Understand the Proxy Configuration parameters discussed in Appendix B, Java Properties Reference.
Procedure 3.2. Configure a Tomcat Worker Node
Add a Listener to Tomcat
Add the followingListenerelement beneath the other Listener elements inJWS_HOME/tomcat<VERSION>/conf/server.xml.<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true" stickySession="true" stickySessionForce="false" stickySessionRemove="true" />
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true" stickySession="true" stickySessionForce="false" stickySessionRemove="true" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Give the Worker a Unique Identity
EditJWS_HOME/tomcat<VERSION>/conf/server.xmland add thejvmRouteattribute and value to theEngineelement, as shown below:<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker01">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker01">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure STATUS MCMP Message Frequency
Tomcat worker nodes periodically send status messages containing their current load status to the Apache HTTP Server balancer. The default frequency of these messages is 10 seconds. If you have hundreds of worker nodes, the STATUS MCMP Messages can increase traffic congestion on your Apache HTTP Server network.You can configure the MCMP message frequency by modifying theorg.jboss.modcluster.container.catalina.status-frequencyJava property. By default, the property accepts values in seconds*10. For example, setting the property to1means 10 seconds. The example below demonstrates the frequency set to 60 seconds.-Dorg.jboss.modcluster.container.catalina.status-frequency=6
-Dorg.jboss.modcluster.container.catalina.status-frequency=6Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional Step: Configure Firewall for Proxy Server Advertisements
A proxy server using mod_cluster can advertise itself via UDP multicast. Most operating system firewalls block this by default. To enable server advertising and receive these multicast messages, open port 23364 for UDP connections on the worker node's firewall.For Red Hat Enterprise Linux 6
/sbin/iptables -A INPUT -m state --state NEW -m udp -p udp --dport 23364 -j ACCEPT -m comment -comment "receive mod_cluster proxy server advertisements"
/sbin/iptables -A INPUT -m state --state NEW -m udp -p udp --dport 23364 -j ACCEPT -m comment -comment "receive mod_cluster proxy server advertisements"Copy to Clipboard Copied! Toggle word wrap Toggle overflow If Automatic Proxy Discovery is not used, configure worker nodes with a static list of proxies. In this case you can safely ignore the following warning message:[warning] mod_advertise: ServerAdvertise Address or Port not defined, Advertise disabled!!!
[warning] mod_advertise: ServerAdvertise Address or Port not defined, Advertise disabled!!!Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7
firewall-cmd --permanent --zone=public --add-port=23364/udp
firewall-cmd --permanent --zone=public --add-port=23364/udpCopy to Clipboard Copied! Toggle word wrap Toggle overflow For Microsoft Windows, using PowerShell
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=in action=allow protocol=UDP localport=23364"' Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=out action=allow protocol=UDP localport=23364"'
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=in action=allow protocol=UDP localport=23364"' Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=out action=allow protocol=UDP localport=23364"'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2.2.2. Configuring a Worker Node with a Static Proxy List リンクのコピーリンクがクリップボードにコピーされました!
- JBoss Web Server worker node configured. See Section 3.2.2.1, “Configuring a Tomcat Worker Node”.
- Understand the Proxy Configuration parameters, detailed in Appendix B, Java Properties Reference.
Procedure 3.3. Configure JBoss Web Server Worker Node with a Static Proxy List
Define a mod_cluster listener, and Disable Dynamic Proxy Discovery
EditJWS_HOME/tomcat<VERSION>/conf/server.xml, and add a <Listener> element to theserver.xmlfile. Set theadvertiseproperty of the ModClusterListener to false. For example:<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true"/>
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a static proxy server list
Add a comma separated list of proxies in the form of IP_ADDRESS:PORT as theproxyListproperty. For example:Example 3.2. Example Static Proxy List
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true" proxyList="10.33.144.3:6666,10.33.144.1:6666"/>
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true" proxyList="10.33.144.3:6666,10.33.144.1:6666"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. WebSocket on Tomcat リンクのコピーリンクがクリップボードにコピーされました!
4.1. About WebSocket リンクのコピーリンクがクリップボードにコピーされました!
4.2. Implementing WebSocket on Tomcat リンクのコピーリンクがクリップボードにコピーされました!
- Configuring write timeout
- Configuring incoming binary messages
- Configuring incoming text messages
- Configuring additional programmatic deployment
- Configuring callbacks for asynchronous writes
- Configuring timeout for IO operations while establishing the connections
You can change the write timeout in blocking mode by using the org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT property. The property accepts values in milliseconds. The default value is 20000 milliseconds (20 seconds).
To configure incoming binary messages, MessageHandler.Partial must be defined. If MessageHandler.Partial is not defined then incoming binary messages must be buffered so that the entire message is delivered in a single call to MessageHandler.Whole.
org.apache.tomcat.websocket.binaryBufferSize.
To configure incoming text messages, MessageHandler.Partial must be defined. If MessageHandler.Partial is not defined then incoming text messages must be buffered so that the entire message is delivered in a single call to MessageHandler.Whole.
org.apache.tomcat.websocket.textBufferSize.
Java WebSocket specification 1.0 does not allow programmatic deployment after the first endpoint has started a WebSocket handshake. However, Tomcat by default allows additional programmatic deployment. Additional programmatic deployment can be done by using the servlet context initialization parameter org.apache.tomcat.websocket.noAddAfterHandshake.
org.apache.tomcat.websocket.STRICT_SPEC_COMPLIANCE to true to change the default setting.
Callbacks for asynchronous writes need to be performed on a different thread to the thread that initiated the write. The container thread pool is not exposed via the Servlet API. Hence the WebSocket implementation has to provide its own thread pool.
org.apache.tomcat.websocket.executorCoreSizeThe core size of the executor thread pool. If not set, the default of 0 (zero) is used.org.apache.tomcat.websocket.executorMaxSizeThe maximum permitted size of the executor thread pool. If not set, the default of 10 is used.org.apache.tomcat.websocket.executorKeepAliveTimeSecondsThe maximum time an idle thread will remain in the executor thread pool until it is terminated. If not specified, the default of 60 seconds is used.
The timeout for IO operations while establishing the connections is controlled by userProperties of the provided javax.websocket.ClientEndpointConfig. You can change timeout by changing the org.apache.tomcat.websocket.IO_TIMEOUT_MS property. The property accepts the values in milliseconds. The default value is 5000 (5 seconds).
userProperties of the provided javax.websocket.ClientEndpointConfig.
org.apache.tomcat.websocket.SSL_CONTEXTorg.apache.tomcat.websocket.SSL_PROTOCOLSorg.apache.tomcat.websocket.SSL_TRUSTSTOREorg.apache.tomcat.websocket.SSL_TRUSTSTORE_PWD
org.apache.tomcat.websocket.SSL_TRUSTSTORE and org.apache.tomcat.websocket.SSL_TRUSTSTORE_PWD properties are ignored if the org.apache.tomcat.websocket.SSL_CONTEXT property is set.
Chapter 5. Online Certificate Status Protocol リンクのコピーリンクがクリップボードにコピーされました!
5.1. Configuring Apache HTTP Server for SSL Connections リンクのコピーリンクがクリップボードにコピーされました!
Procedure 5.1. Configure Apache HTTP Server for SSL Connections
- Install mod_ssl using the following command:
yum install mod_ssl
# yum install mod_sslCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit
JWS_HOME/httpd/conf.d/ssl.conf, and addServerName,SSLCertificateFile, andSSLCertificateKeyFile:<VirtualHost _default_:443> ServerName www.example.com:443 SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
<VirtualHost _default_:443> ServerName www.example.com:443 SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow ServerNamemust match the Common Name (CN) of the SSL certificate. If theServerNamedoes not match the CN, client browsers display domain name mismatch errors.- The
SSLCertificateFileis the private key associated with the certificate (the public key). - Verify that the Listen directive in the
ssl.conffile is correct as per your configuration. For example, if an IP address is specified, it must match the IP address the httpd service is bound to.
- Restart httpd using the following command:
service httpd restart
# service httpd restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. About Online Certificate Status Protocol (OCSP) リンクのコピーリンクがクリップボードにコピーされました!
5.3. Using Online Certificate Status Protocol with Apache HTTP Server リンクのコピーリンクがクリップボードにコピーされました!
Note
5.4. Configure Apache HTTP Server to Validate OCSP Certificates リンクのコピーリンクがクリップボードにコピーされました!
Example 5.1.
SSLOCSPEnable attribute to enable OCSP validation:
5.5. Verify Your OCSP Configuration リンクのコピーリンクがクリップボードにコピーされました!
openssl ocsp -issuer cacert.crt -cert client.cert -url http://HOST:PORT -CA ocsp_ca.cert -VAfile ocsp.cert
# openssl ocsp -issuer cacert.crt -cert client.cert -url http://HOST:PORT -CA ocsp_ca.cert -VAfile ocsp.cert
-issueris the Certificate Authority certificate.-certis the Client certificate which you want to verify.-urlis the http server validating Certificate (OCSP).-CAis the CA certificate for verifying the Apache HTTP Server server certificate.-VAfileis the OCSP Responder certificate.
Chapter 6. Working Examples リンクのコピーリンクがクリップボードにコピーされました!
6.1. Complete Working Example リンクのコピーリンクがクリップボードにコピーされました!
A proxy server listening on localhost:
Edit JWS_HOME/tomcat<VERSION>/conf/server.xml, and add the following listener element to configure the worker for Tomcat:
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true"/>
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true"/>
Following are a set of example firewall rules using iptables, for a cluster node on the 192.168.1.0/24 subnet.
/sbin/iptables -I INPUT 5 -p udp -d 224.0.1.0/24 -j ACCEPT -m comment --comment "mod_cluster traffic" /sbin/iptables -I INPUT 6 -p udp -d 224.0.0.0/4 -j ACCEPT -m comment --comment "JBoss Cluster traffic" /sbin/iptables -I INPUT 9 -p udp -s 192.168.1.0/24 -j ACCEPT -m comment --comment "cluster subnet for inter-node communication" /sbin/iptables -I INPUT 10 -p tcp -s 192.168.1.0/24 -j ACCEPT -m comment --comment "cluster subnet for inter-node communication" /etc/init.d/iptables save
/sbin/iptables -I INPUT 5 -p udp -d 224.0.1.0/24 -j ACCEPT -m comment --comment "mod_cluster traffic"
/sbin/iptables -I INPUT 6 -p udp -d 224.0.0.0/4 -j ACCEPT -m comment --comment "JBoss Cluster traffic"
/sbin/iptables -I INPUT 9 -p udp -s 192.168.1.0/24 -j ACCEPT -m comment --comment "cluster subnet for inter-node communication"
/sbin/iptables -I INPUT 10 -p tcp -s 192.168.1.0/24 -j ACCEPT -m comment --comment "cluster subnet for inter-node communication"
/etc/init.d/iptables save
6.2. mod_auth_kerb Example リンクのコピーリンクがクリップボードにコピーされました!
6.2.1. mod_auth_kerb Example Prerequisites リンクのコピーリンクがクリップボードにコピーされました!
- Install mod_auth_kerb on Red Hat Enterprise Linux.
- Install curl with GSS-negotiated support.
- Configure and run a Kerberos or LDAP server (for example ApacheDS) on the same host as your Red Hat JBoss Web Server.
- Create the following LDAP users:
- Create the user
krbtgt:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create the user
ldap:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create the user
HTTP:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create user
hnelson(test user):Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2.2. Configure the Kerberos Client リンクのコピーリンクがクリップボードにコピーされました!
Procedure 6.1. Configure the Kerberos Client
Create the Kerberos Configuration File
Create thekrb5.confconfiguration file in the/etcdirectory and add the following to the file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Key Tab
Create a key tab in the/etc/httpdfolder with the following contents:Copy to Clipboard Copied! Toggle word wrap Toggle overflow As the root user, run the following commands to apply the correct group and permissions to the key tab:chgrp apache /etc/httpd/krb5.keytab chmod 640 /etc/httpd/krb5.keytab
# chgrp apache /etc/httpd/krb5.keytab # chmod 640 /etc/httpd/krb5.keytabCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the Hosts File
Ensure that the following host configuration is included in the/etc/hostsfile:127.0.0.1 localhost
127.0.0.1 localhostCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2.3. Configure mod_auth_kerb リンクのコピーリンクがクリップボードにコピーされました!
Procedure 6.2. Configure mod_auth_kerb
- Create the
auth_kerb.confconfiguration file in theJWS_HOME/httpd/conf.d/folder and add the following information to the file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2.4. Test the Kerberos Authentication リンクのコピーリンクがクリップボードにコピーされました!
Procedure 6.3. Test the Kerberos Authentication
Create a Test Page
Create a test page namedauth_kerb_page.htmlinJWS_HOME/httpd/www/html/kerberostest/.Add the Contents of the Test Page
Add the following contents to the test page (auth_kerb_page.html):<html> <body> <h1>mod_auth_kerb successfully authenticated!</h1> </body> </html><html> <body> <h1>mod_auth_kerb successfully authenticated!</h1> </body> </html>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Set Log Level
Optionally, set the log level for debugging inJWS_HOME/httpd/conf/httpd.conf.Start httpd
The the Installation Guide for details.Test Authentication
Test the authentication as follows:- Initiate Kerberos authentication for the test user
hnelson:kinit hnelson
$ kinit hnelsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow - View the details for the test user
hnelson:klist
$ klistCopy to Clipboard Copied! Toggle word wrap Toggle overflow A result similar to the following appears:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Testing Apache HTTP Server Kerberos Authentication
Test Apache HTTP Server Kerberos authentication as follows:curl --negotiate -u : http://localhost/kerberostest/auth_kerb_page.html
$ curl --negotiate -u : http://localhost/kerberostest/auth_kerb_page.htmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow If working correctly, the following result appears:<html> <body> <h1>mod_auth_kerb successfully authenticated!</h1> </body> </html><html> <body> <h1>mod_auth_kerb successfully authenticated!</h1> </body> </html>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Appendix A. Reference リンクのコピーリンクがクリップボードにコピーされました!
A.1. Apache Modules リンクのコピーリンクがクリップボードにコピーされました!
A.1.1. mod_manager.so リンクのコピーリンクがクリップボードにコピーされました!
LoadModule manager_module modules/mod_manager.so
LoadModule manager_module modules/mod_manager.so
<VirtualHost> element are as follows:
- EnableMCPMReceive
- Allows the
VirtualHostto receive the mod_cluster Protocol Message (MCPM) from nodes. Add oneEnableMCPMRecievedirective to the httpd configuration to allowmod_clusterto operate correctly.EnableMCPMRecievemust be added in theVirtualHostconfiguration, at the location whereadvertiseis configured. - MaxMCMPMaxMessSize
- Defines the maximum size of mod_cluster Management Protocol (MCMP) messages. The default value for this is calculated from other
Maxdirectives. The minimum value for this is1024. - AllowDisplay
- Toggles the additional display on the
mod_cluster-managermain page. The default value isoff, which causes only version information to display on themod_cluster-managermain page. - AllowCmd
- Toggles permissions for commands using
mod_cluster-managerURL. The default value ison, which allows commands. - ReduceDisplay
- Toggles the reduction of information displayed on the
mod_cluster-managerpage. Reducing the information allows more nodes to display on the page. The default value isoffwhich allows all the available information to display. - MemManagerFile
- Defines the location for the files in which mod_manager stores configuration details. mod_manager also uses this location for generated keys for shared memory and lock files. This must be an absolute path name. It is recommended that this path be on a local drive, and not a NFS share. The default value is
/logs/. - Maxcontext
- The maximum number of contexts mod_cluster will use. The default value is
100. - Maxnode
- The maximum number of worker nodes mod_cluster will use. The default value is
20. - Maxhost
- The maximum number of hosts (aliases) mod_cluster will use. This is also the maximum number of load balancers. The default value is
10. - Maxsessionid
- The maximum number of active session identifiers stored. A session is considered inactive when no information is received from that session within five minutes. This is used for demonstration and debugging purposes only. The default value is
0, which disables this logic. - ManagerBalancerName
- The name of the load balancer to use when the worker node does not provide a load balancer name. The default value is
mycluster. - PersistSlots
- When set to
on, nodes, aliases and contexts are persisted in files. The default value isoff. - CheckNonce
- When set to
on, session identifiers are checked to ensure that they are unique, and have not occurred before. The default ison.Warning
Setting this directive tooffcan leave your server vulnerable to replay attacks. - SetHandler mod_cluster-manager
- Defines a handler to display information about worker nodes in the cluster. This is defined in the
Locationelement:<Location $LOCATION> SetHandler mod_cluster-manager Require ip 127.0.0.1 </Location>
<Location $LOCATION> SetHandler mod_cluster-manager Require ip 127.0.0.1 </Location>Copy to Clipboard Copied! Toggle word wrap Toggle overflow When accessing the $LOCATION defined in theLocationelement in your browser, you will see something like the following. (In this case, $LOCATION was also defined asmod_cluster-handler.)
Maxsessionid is 0.
A.1.2. mod_proxy_cluster.so リンクのコピーリンクがクリップボードにコピーされました!
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
<VirtualHost> element to change load balancing behavior.
mod_proxy_cluster directives
- CreateBalancers
- Defines how load balancers are created in the Apache HTTP Server virtual hosts. The following values are valid in
CreateBalancers:- 0
- Create load balancers in all virtual hosts defined in Apache HTTP Server. Remember to configure the load balancers in the
ProxyPassdirective. - 1
- Do not create balancers. When using this value, you must also define the load balancer name in
ProxyPassorProxyPassMatch. - 2
- Create only the main server. This is the default value for
CreateBalancers.
- UseAlias
- Defines whether to check that the defined
Aliascorresponds to theServerName. The following values are valid forUseAlias:- 0
- Ignore Alias information from worker nodes. This is the default value for
UseAlias. - 1
- Verify that the defined alias corresponds to a worker node's server name.
- LBstatusRecalTime
- Defines the interval in seconds between the proxy calculating the status of a worker node. The default interval is 5 seconds.
- ProxyPassMatch; ProxyPass
ProxyPassmaps remote servers into the local server namespace. If the local server has an addresshttp://local.com/, then the followingProxyPassdirective would convert a local request forhttp://local.com/requested/file1into a proxy request forhttp://worker.local.com/file1.ProxyPass /requested/ http://worker.local.com/
ProxyPass /requested/ http://worker.local.com/Copy to Clipboard Copied! Toggle word wrap Toggle overflow ProxyPassMatchuses Regular Expressions to match local paths to which the proxied URL should apply.For either directive,!indicates that a specified path is local, and a request for that path should not be routed to a remote server. For example, the following directive specifies that.giffiles should be served locally.ProxyPassMatch ^(/.*\.gif)$ !
ProxyPassMatch ^(/.*\.gif)$ !Copy to Clipboard Copied! Toggle word wrap Toggle overflow
A.1.3. mod_advertise.so リンクのコピーリンクがクリップボードにコピーされました!
VirtualHost element. Its identifier in the following code snippet is advertise_module.
LoadModule advertise_module modules/mod_advertise.so
LoadModule advertise_module modules/mod_advertise.so
- ServerAdvertise
- Defines how the advertising mechanism is used.When set to
On, the advertising mechanism is used to tell worker nodes to send status information to this proxy. You can also specify a hostname and port with the following syntax:ServerAdvertise On http://hostname:port/. This is only required when using a name-based virtual host, or when a virtual host is not defined.The default value isOff. When set toOff, the proxy does not advertise its location. - AdvertiseGroup
- Defines the multicast address to advertise on. The syntax is
AdvertiseGroup address:port, where address must correspond toAdvertiseGroupAddress, and port must correspond toAdvertisePortin your worker nodes.If your worker node is JBoss EAP-based, and the-uswitch is used at startup, the defaultAdvertiseGroupAddressis the value passed via the-uswitch.The default value is224.0.1.105:23364. If a port is not specified, the port defaults to23364. - AdvertiseFrequency
- The interval (in seconds) between multicast messages advertising the IP address and port. The default value is
10. - AdvertiseSecurityKey
- Defines a string used to identify mod_cluster in JBoss Web Server. By default this directive is not set and no information is sent.
- AdvertiseManagerUrl
- Defines the URL that the worker node should use to send information to the proxy server. By default this directive is not set and no information is sent.
- AdvertiseBindAddress
- Defines the address and port over which to send multicast messages. The syntax is
AdvertiseBindAddress address:port. This allows an address to be specified on machines with multiple IP addresses. The default value is0.0.0.0:23364.
A.1.4. mod_proxy.so リンクのコピーリンクがクリップボードにコピーされました!
proxy_module.
Mod_proxy directives such as ProxyIOBufferSize are used to configure mod_cluster.
A.1.5. mod_proxy_ajp.so リンクのコピーリンクがクリップボードにコピーされました!
Mod_proxy.so is required to use this module.
A.1.6. mod_cluster_slotmem リンクのコピーリンクがクリップボードにコピーされました!
mod_cluster_slotmem does not require any configuration directives.
A.2. workers.properties リンクのコピーリンクがクリップボードにコピーされました!
JWS_HOME/httpd/conf/workers.properties. This file specifies where the different Servlet containers are located, and how calls should be load-balanced across them.
workers.properties file contains two sections:
- Global Properties
- This section contains directives that apply to all workers.
- Worker Properties
- This section contains directives that apply to each individual worker.
worker.worker_name.directive
- worker
- The constant prefix for all worker properties.
- worker_name
- The arbitrary name given to the worker. For example: node1, node_01, Node_1.
- directive
- The specific directive required.
Note
worker.properties configuration directives, see Apache Tomcat Connector - Reference Guide
worker.properties Global Directives
- worker.list
- Specifies the list of worker names used by mod_jk. The workers in this list are available to map requests to.
Note
A single node configuration which is not managed by a load balancer must be set toworker.list=[worker name].
workers.properties Mandatory Directives
- type
- Specifies the type of worker, which determines the directives applicable to the worker. The default value is
ajp13, which is the preferred worker type to select for communication between the web server and Apache httpd Server.Other values includeajp14,lb,status.For detailed information about ajp13, see The Apache Tomcat Connector - AJP Protocol Reference
workers.properties Connection Directives
- host
- The hostname or IP address of the worker. The worker node must support the ajp13 protocol stack. The default value is
localhost.You can specify theportdirective as part of the host directive by appending the port number after the hostname or IP address. For example:worker.node1.host=192.168.2.1:8009orworker.node1.host=node1.example.com:8009 - port
- The port number of the remote server instance listening for defined protocol requests. The default value is
8009, which is the default listen port for AJP13 workers. If you are using AJP14 workers, the default port is8011. - ping_mode
- Specifies the conditions under which connections are probed for their current network health.The probe uses an empty AJP13 packet for the CPing, and expects a CPong in return, within a specified timeout.You specify the conditions by using a combination of the directive flags. The flags are not comma-separated. For example, a correct directive flag set is
worker.node1.ping_mode=CI- C (connect)
- Specifies the connection is probed once after connecting to the server. You specify the timeout using the
connect_timeoutdirective, otherwise the value forping_timeoutis used. - P (prepost)
- Specifies the connection is probed before sending each request to the server. You specify the timeout using the
prepost_timeoutdirective, otherwise the value forping_timeoutis used. - I (interval)
- Specifies the connection is probed during regular internal maintenance cycles. You specify the idle time between each interval using the
connection_ping_intervaldirective, otherwise the value forping_timeoutis used. - A (all)
- The most common setting, which specifies all directive flags are applied. For information about the
*_timeoutadvanced directives, refer directly to Apache Tomcat Connector - Reference Guide.
- ping_timeout
- Specifies the time to wait for CPong answers to a CPing connection probe (see
ping_mode). The default value is 10000 (milliseconds).
worker.properties Load Balancing Directives
- lbfactor
- Specifies the load-balancing factor for an individual worker, and is only specified for a member worker of a load balancer.This directive defines the relative amount of HTTP request load distributed to the worker compared to other workers in the cluster.A common example where this directive applies is where you want to differentiate servers with greater processing power than others in the cluster. For example, if you require a worker to take three times the load than other workers, specify
worker.worker name.lbfactor=3 - balance_workers
- Specifies the worker nodes that the load balancer must manage. The directive can be used multiple times for the same load balancer, and consists of a comma-separated list of worker names as specified in the workers.properties file.
- sticky_session
- Specifies whether requests for workers with SESSION IDs are routed back to the same worker. The default is
0(false). When set to1(true), load balancer persistence is enabled.For example, if you specifyworker.loadbalancer.sticky_session=0, each request is load balanced between each node in the cluster. In other words, different requests for the same session will go to different servers based on server load.Ifworker.loadbalancer.sticky_session=1, each session is persisted (locked) to one server until the session is terminated, providing that server is available.
Appendix B. Java Properties Reference リンクのコピーリンクがクリップボードにコピーされました!
B.1. Proxy Configuration リンクのコピーリンクがクリップボードにコピーされました!
- During server startup.
- When a proxy is detected through the advertise mechanism.
- During error recovery, when a proxy's configuration is reset.
| Value | Default | Description |
|---|---|---|
| stickySession | true | Specifies whether subsequent requests for a given session should be routed to the same node, if possible. |
| stickySessionRemove | false | Specifies whether the httpd proxy should remove session stickiness if the balancer is unable to route a request to the node to which it is stuck. This property is ignored if stickySession is false. |
| stickySessionForce | true | Specifies whether the httpd proxy should return an error if the balancer is unable to route a request to the node to which it is stuck. This property is ignored if stickySession is false. |
| workerTimeout | -1 | Specifies the number of seconds to wait for a worker to become available to handle a request. When all the workers of a balancer are unusable, mod_cluster will retry after a while (workerTimeout/100) to find an usable worker. A value of -1 indicates that the httpd will not wait for a worker to be available and will return an error if no workers are available. |
| maxAttempts | 1 | Specifies the number of times the httpd proxy will attempt to send a given request to a worker before aborting. The minimum value is 1: try once before aborting. |
| flushPackets | false | Specifies whether packet flushing is enabled or disabled. |
| flushWait | -1 | Specifies the time to wait before flushing packets. A value of -1 means wait forever. |
| ping | 10 | Time to wait (in seconds) for a pong answer to a ping. |
| smax | - | Specifies the soft maximum idle connection count. The maximum value is determined by the httpd thread configuration (ThreadsPerChild or 1). |
| ttl | 60 | Specifies the time (in seconds) idle connections persist, above the smax threshold. |
| nodeTimeout | -1 | Specifies the time (in seconds) mod_cluster waits for the back-end server response before returning an error. mod_cluster always uses a cping/cpong before forwarding a request. The connectiontimeout value used by mod_cluster is the ping value. |
| balancer | mycluster | Specifies the name of the load-balancer. |
| loadBalancingGroup | - | Specifies the load balancing among jvmRoutes within the same load balancing group. A loadBalancingGroup is conceptually equivalent to a mod_jk domain directive. |
B.2. mod_cluster Proxy and Proxy Discovery Configuration Attributes リンクのコピーリンクがクリップボードにコピーされました!
| Attribute | Property | Default Value |
|---|---|---|
| proxy-list | proxyList | - |
| proxy-url | proxyURL | - |
| advertise | advertise | true |
| advertise-security-key | advertiseSecurityKey | - |
| excluded-contexts | excludedContexts | - |
| auto-enable-contexts | autoEnableContexts | true |
| stop-context-timeout | stopContextTimeout | 10 seconds (in seconds) |
| socket-timeout | nodeTimeout | 20 seconds (in milliseconds) |
Note
nodeTimeout is not defined, the ProxyTimeout directive, Proxy, is used. If ProxyTimeout is not defined, the server timeout (Timeout) is used (the default is 300 seconds). nodeTimeout, ProxyTimeout and Timeout are set at the socket level.
| Attribute | Property | Default Value |
|---|---|---|
| sticky-session | stickySession | true |
| sticky-session-remove | stickySessionRemove | false |
| sticky-session-force | stickySessionForce | true |
| node-timeout | workerTimeout | -1 |
| max-attempts | maxAttempts | 1 |
| flush-packets | flushPackets | false |
| flush-wait | flushWait | -1 |
| ping | ping | 10 |
| smax | smax | -1 (uses the default value) |
| ttl | ttl | -1 (uses the default value) |
| domain | loadBalancingGroup | - |
| load-balancing-group | loadBalancingGroup | - |
B.3. Load Configuration リンクのコピーリンクがクリップボードにコピーされました!
mod_cluster is configured with Tomcat:
| Attribute | Default Value | Description |
|---|---|---|
| loadMetricClass | org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric | This is the class name of an object that is implementing org.jboss.load.metric.LoadMetric. |
| loadMetricCapacity | 1 | This is the capacity of the load metric defined via the loadMetricClass property. |
| loadHistory | 9 | This is the number of historic load values that must be considered in the load balance factor computation. |
| loadDecayFactor | 2 | This is the factor by which the historic load values decrease in significance. |
Appendix C. Revision History リンクのコピーリンクがクリップボードにコピーされました!
| Revision History | |||
|---|---|---|---|
| Revision 3.0.1-15 | Friday 4 September 2015 | ||
| |||
| Revision 3.0.0-12 | Tue 5 May 2015 | ||
| |||