Nexus kills forwarding from apache to tomcat - ssl

I'm trying to run Nexus as a war in tomcat6. It deploys, starts and initializes and doesn't show any errors in the logs but it kills forwarding from apache to tomcat.
We are using libapache2-mod-jk and this should be correctly configured. Hudson is also running as a war and also doesn't work anymore. If I remove nexus from tomcat everything works fine again.
The error I found was in /var/log/apache2/mod_jk.log:
[error] ajp_send_request::jk_ajp_common.c (1630): (ajp13_worker) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
Config looks like this /etc/libapache2-mod-jk/workers.properties
#------ worker list ------------------------------------------
#---------------------------------------------------------------------
#
#
# The workers that your plugins should create and work with
#
worker.list=ajp13_worker
#
#------ ajp13_worker WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#
#
# Defining a worker named ajp13_worker and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.ajp13_worker.lbfactor=1
#
# Specify the size of the open connection cache.
#worker.ajp13_worker.cachesize
#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#
#
# The loadbalancer (type lb) workers perform wighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# workers.
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=ajp13_worker
And in /etc/apache2/sites-available/default-ssl
######## Tomcat
JkMount /agilefant/* ajp13_worker
JkMount /hudson/* ajp13_worker
JKMount /nexus/* ajp13_worker
Any idea?

You should not run Nexus as a war. This is not recommended and about to be completely deprecated. Run it from the bundle download that has a preconfigure Eclipse Jetty instance in it.

Related

How should Tinyproxy be configured to route traffic back to the client properly?

I'm trying to set up a simple reverse proxy with Tinyproxy.
I'm using something essentially identical as far as I can tell to the default configuration which can be found here, posted at the bottom of this question.
When I try to either curl or visit localhost:8888/google/, I get an empty response. Tinyproxy running in foreground mode shows the following:
INFO Aug 26 20:36:01 [39567]: Initializing tinyproxy ...
INFO Aug 26 20:36:01 [39567]: Reloading config file
INFO Aug 26 20:36:01 [39567]: Setting "Via" header to 'tinyproxy'
INFO Aug 26 20:36:01 [39567]: Added reverse proxy rule: /google/ -> http://www.google.com/
INFO Aug 26 20:36:01 [39567]: listen_sock called with addr = '(NULL)'
INFO Aug 26 20:36:01 [39567]: trying to listen on host[::], family[30], socktype[1], proto[6]
INFO Aug 26 20:36:01 [39567]: listening on fd [5]
INFO Aug 26 20:36:01 [39567]: trying to listen on host[0.0.0.0], family[2], socktype[1], proto[6]
INFO Aug 26 20:36:01 [39567]: listening on fd [6]
WARNING Aug 26 20:36:01 [39567]: Not running as root, so not changing UID/GID.
INFO Aug 26 20:36:01 [39567]: Creating child number 1 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 2 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 3 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 4 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 5 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 6 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 7 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 8 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 9 of 10 ...
INFO Aug 26 20:36:01 [39567]: Creating child number 10 of 10 ...
INFO Aug 26 20:36:01 [39567]: Finished creating all children.
INFO Aug 26 20:36:01 [39567]: Setting the various signals.
INFO Aug 26 20:36:01 [39567]: Starting main loop. Accepting connections.
CONNECT Aug 26 20:36:04 [39577]: Connect (file descriptor 10): localhost [::1]
CONNECT Aug 26 20:36:04 [39577]: Request (file descriptor 10): GET /google/ HTTP/1.1
CONNECT Aug 26 20:36:04 [39577]: Rewriting URL: /google/ -> http://www.google.com/
INFO Aug 26 20:36:04 [39577]: No upstream proxy for www.google.com
INFO Aug 26 20:36:04 [39577]: opensock: opening connection to www.google.com:80
and curl returns curl: (52) Empty reply from server
I note that the final line of the logs changes if I change the route for google.com to https. In this case, I get:
INFO Aug 26 20:37:45 [39616]: No upstream proxy for localhost
INFO Aug 26 20:37:45 [39616]: opensock: opening connection to localhost:8888
The config is as follows:
##
## tinyproxy.conf -- tinyproxy daemon configuration file
##
## This example tinyproxy.conf file contains example settings
## with explanations in comments. For decriptions of all
## parameters, see the tinproxy.conf(5) manual page.
##
#
# User/Group: This allows you to set the user and group that will be
# used for tinyproxy after the initial binding to the port has been done
# as the root user. Either the user or group name or the UID or GID
# number may be used.
#
User nobody
Group nobody
#
# Port: Specify the port which tinyproxy will listen on. Please note
# that should you choose to run on a port lower than 1024 you will need
# to start tinyproxy using root.
#
Port 8888
#
# Listen: If you have multiple interfaces this allows you to bind to
# only one. If this is commented out, tinyproxy will bind to all
# interfaces present.
#
#Listen 192.168.0.1
#
# Bind: This allows you to specify which interface will be used for
# outgoing connections. This is useful for multi-home'd machines where
# you want all traffic to appear outgoing from one particular interface.
#
#Bind 192.168.0.1
#
# BindSame: If enabled, tinyproxy will bind the outgoing connection to the
# ip address of the incoming connection.
#
#BindSame yes
#
# Timeout: The maximum number of seconds of inactivity a connection is
# allowed to have before it is closed by tinyproxy.
#
Timeout 600
#
# ErrorFile: Defines the HTML file to send when a given HTTP error
# occurs. You will probably need to customize the location to your
# particular install. The usual locations to check are:
# /usr/local/share/tinyproxy
# /usr/share/tinyproxy
# /etc/tinyproxy
#
#ErrorFile 404 "#pkgdatadir#/404.html"
#ErrorFile 400 "#pkgdatadir#/400.html"
#ErrorFile 503 "#pkgdatadir#/503.html"
#ErrorFile 403 "#pkgdatadir#/403.html"
#ErrorFile 408 "#pkgdatadir#/408.html"
#
# DefaultErrorFile: The HTML file that gets sent if there is no
# HTML file defined with an ErrorFile keyword for the HTTP error
# that has occured.
#
DefaultErrorFile "#pkgdatadir#/default.html"
#
# StatHost: This configures the host name or IP address that is treated
# as the stat host: Whenever a request for this host is received,
# Tinyproxy will return an internal statistics page instead of
# forwarding the request to that host. The default value of StatHost is
# #TINYPROXY_STATHOST#.
#
#StatHost "#TINYPROXY_STATHOST#"
#
#
# StatFile: The HTML file that gets sent when a request is made
# for the stathost. If this file doesn't exist a basic page is
# hardcoded in tinyproxy.
#
StatFile "#pkgdatadir#/stats.html"
#
# LogFile: Allows you to specify the location where information should
# be logged to. If you would prefer to log to syslog, then disable this
# and enable the Syslog directive. These directives are mutually
# exclusive. If neither Syslog nor LogFile are specified, output goes
# to stdout.
#
#LogFile "#localstatedir#/log/tinyproxy/tinyproxy.log"
#
# Syslog: Tell tinyproxy to use syslog instead of a logfile. This
# option must not be enabled if the Logfile directive is being used.
# These two directives are mutually exclusive.
#
#Syslog On
#
# LogLevel: Warning
#
# Set the logging level. Allowed settings are:
# Critical (least verbose)
# Error
# Warning
# Notice
# Connect (to log connections without Info's noise)
# Info (most verbose)
#
# The LogLevel logs from the set level and above. For example, if the
# LogLevel was set to Warning, then all log messages from Warning to
# Critical would be output, but Notice and below would be suppressed.
#
LogLevel Info
#
# PidFile: Write the PID of the main tinyproxy thread to this file so it
# can be used for signalling purposes.
# If not specified, no pidfile will be written.
#
#PidFile "#localstatedir#/run/tinyproxy/tinyproxy.pid"
#
# XTinyproxy: Tell Tinyproxy to include the X-Tinyproxy header, which
# contains the client's IP address.
#
#XTinyproxy Yes
#
# Upstream:
#
# Turns on upstream proxy support.
#
# The upstream rules allow you to selectively route upstream connections
# based on the host/domain of the site being accessed.
#
# Syntax: upstream type (user:pass#)ip:port ("domain")
# Or: upstream none "domain"
# The parts in parens are optional.
# Possible types are http, socks4, socks5, none
#
# For example:
# # connection to test domain goes through testproxy
# upstream http testproxy:8008 ".test.domain.invalid"
# upstream http testproxy:8008 ".our_testbed.example.com"
# upstream http testproxy:8008 "192.168.128.0/255.255.254.0"
#
# # upstream proxy using basic authentication
# upstream http user:pass#testproxy:8008 ".test.domain.invalid"
#
# # no upstream proxy for internal websites and unqualified hosts
# upstream none ".internal.example.com"
# upstream none "www.example.com"
# upstream none "10.0.0.0/8"
# upstream none "192.168.0.0/255.255.254.0"
# upstream none "."
#
# # connection to these boxes go through their DMZ firewalls
# upstream http cust1_firewall:8008 "testbed_for_cust1"
# upstream http cust2_firewall:8008 "testbed_for_cust2"
#
# # default upstream is internet firewall
# upstream http firewall.internal.example.com:80
#
# You may also use SOCKS4/SOCKS5 upstream proxies:
# upstream socks4 127.0.0.1:9050
# upstream socks5 socksproxy:1080
#
# The LAST matching rule wins the route decision. As you can see, you
# can use a host, or a domain:
# name matches host exactly
# .name matches any host in domain "name"
# . matches any host with no domain (in 'empty' domain)
# IP/bits matches network/mask
# IP/mask matches network/mask
#
#Upstream http some.remote.proxy:port
#
# MaxClients: This is the absolute highest number of threads which will
# be created. In other words, only MaxClients number of clients can be
# connected at the same time.
#
MaxClients 100
#
# MinSpareServers/MaxSpareServers: These settings set the upper and
# lower limit for the number of spare servers which should be available.
#
# If the number of spare servers falls below MinSpareServers then new
# server processes will be spawned. If the number of servers exceeds
# MaxSpareServers then the extras will be killed off.
#
MinSpareServers 5
MaxSpareServers 20
#
# StartServers: The number of servers to start initially.
#
StartServers 10
#
# MaxRequestsPerChild: The number of connections a thread will handle
# before it is killed. In practise this should be set to 0, which
# disables thread reaping. If you do notice problems with memory
# leakage, then set this to something like 10000.
#
MaxRequestsPerChild 0
#
# Allow: Customization of authorization controls. If there are any
# access control keywords then the default action is to DENY. Otherwise,
# the default action is ALLOW.
#
# The order of the controls are important. All incoming connections are
# tested against the controls based on order.
#
Allow 127.0.0.1
Allow ::1
# BasicAuth: HTTP "Basic Authentication" for accessing the proxy.
# If there are any entries specified, access is only granted for authenticated
# users.
#BasicAuth user password
#
# AddHeader: Adds the specified headers to outgoing HTTP requests that
# Tinyproxy makes. Note that this option will not work for HTTPS
# traffic, as Tinyproxy has no control over what headers are exchanged.
#
#AddHeader "X-My-Header" "Powered by Tinyproxy"
#
# ViaProxyName: The "Via" header is required by the HTTP RFC, but using
# the real host name is a security concern. If the following directive
# is enabled, the string supplied will be used as the host name in the
# Via header; otherwise, the server's host name will be used.
#
ViaProxyName "tinyproxy"
#
# DisableViaHeader: When this is set to yes, Tinyproxy does NOT add
# the Via header to the requests. This virtually puts Tinyproxy into
# stealth mode. Note that RFC 2616 requires proxies to set the Via
# header, so by enabling this option, you break compliance.
# Don't disable the Via header unless you know what you are doing...
#
#DisableViaHeader Yes
#
# Filter: This allows you to specify the location of the filter file.
#
#Filter "#pkgsysconfdir#/filter"
#
# FilterURLs: Filter based on URLs rather than domains.
#
#FilterURLs On
#
# FilterExtended: Use POSIX Extended regular expressions rather than
# basic.
#
#FilterExtended On
#
# FilterCaseSensitive: Use case sensitive regular expressions.
#
#FilterCaseSensitive On
#
# FilterDefaultDeny: Change the default policy of the filtering system.
# If this directive is commented out, or is set to "No" then the default
# policy is to allow everything which is not specifically denied by the
# filter file.
#
# However, by setting this directive to "Yes" the default policy becomes
# to deny everything which is _not_ specifically allowed by the filter
# file.
#
#FilterDefaultDeny Yes
#
# Anonymous: If an Anonymous keyword is present, then anonymous proxying
# is enabled. The headers listed are allowed through, while all others
# are denied. If no Anonymous keyword is present, then all headers are
# allowed through. You must include quotes around the headers.
#
# Most sites require cookies to be enabled for them to work correctly, so
# you will need to allow Cookies through if you access those sites.
#
#Anonymous "Host"
#Anonymous "Authorization"
#Anonymous "Cookie"
#
# ConnectPort: This is a list of ports allowed by tinyproxy when the
# CONNECT method is used. To disable the CONNECT method altogether, set
# the value to 0. If no ConnectPort line is found, all ports are
# allowed.
#
# The following two ports are used by SSL.
#
# ConnectPort 443
# ConnectPort 563
#
# Configure one or more ReversePath directives to enable reverse proxy
# support. With reverse proxying it's possible to make a number of
# sites appear as if they were part of a single site.
#
# If you uncomment the following two directives and run tinyproxy
# on your own computer at port 8888, you can access Google using
# http://localhost:8888/google/ and Wired News using
# http://localhost:8888/wired/news/. Neither will actually work
# until you uncomment ReverseMagic as they use absolute linking.
#
ReversePath "/google/" "https://www.google.com/"
#ReversePath "/wired/" "http://www.wired.com/"
#
# When using tinyproxy as a reverse proxy, it is STRONGLY recommended
# that the normal proxy is turned off by uncommenting the next directive.
#
ReverseOnly Yes
#
# Use a cookie to track reverse proxy mappings. If you need to reverse
# proxy sites which have absolute links you must uncomment this.
#
ReverseMagic Yes
#
# The URL that's used to access this reverse proxy. The URL is used to
# rewrite HTTP redirects so that they won't escape the proxy. If you
# have a chain of reverse proxies, you'll need to put the outermost
# URL here (the address which the end user types into his/her browser).
#
# If not set then no rewriting occurs.
#
ReverseBaseURL "http://localhost:8888/"
So, the question is, what part of the config is incorrect here and what needs to change to have traffic route correctly through?
Set max clients to 10000 and try again. 500 should be ok

Two loadbalacer with apache 2.2(for jboss and apapche tomcat)

I have a apache server with loadbalancer(apache-2.2) and two tomcat nodes(clusters). To communicate with tomcat nodes I'm using mod_jk. I've defined two loadbalancer in apache(by changing httpd.conf and worker property files). Apache is running in port 80. The configuration as follows. iSencer is one of my application.
In httpd.conf
=============
Listen localhost:80
ServerName localhost
DocumentRoot "/home/xx/projects/apache/content" (I've created a seperate root directory as content)
JkMount /iSencer loadbalancer
JkMount /iSencer/ loadbalancer
JkMount /iSencer/* loadbalancer
In worker.properites
====================
worker.list=loadbalancer
#------------------------
# iSencer node 1 - tomcat
#------------------------
worker.iSencer1.type=ajp13
worker.iSencer1.host=localhost
worker.iSencer1.port=8109
#------------------------
# iSencer node 2 - tomcat
#------------------------
worker.iSencer2.type=ajp13
worker.iSencer2.host=localhost
worker.iSencer2.port=8010
# ------------------------
# Load Balancer for yard
# ------------------------
worker.loadbalancer.sticky_session=1
worker.loadbalancer.balanced_workers=iSencer1,iSencer2
worker.loadbalancer.type=lb
worker.loadbalancer.method=B
and there are some changes in tomcat server.xml.So, cluster is working properly.
Now I want to add a jboss server to same apache. But need to run in different loadbalancer. My changes as follows as in httpd.conf in apache.
JkMount /index.html loadbalancer2
JkMount /servlet/* loadbalancer2
worker property
===============
worker.list=loadbalancer, worker.list=loadbalancer2
#------------------------
# tracker node 1
#------------------------
worker.track.port=8009
worker.track.host=localhost
worker.track.type=ajp13
worker.track.lbfactor=1
worker.track.connection_pool_size=10
# ------------------------
# Load Balancer for tracker
# ------------------------
worker.loadbalancer2.sticky_session=1
worker.loadbalancer2.balanced_workers=track
worker.loadbalancer2.type=lb
worker.loadbalancer2.method=B
But after adding jboss to apache as a cluster my tomcat cluster is not working properly ? In browser it will show two JSESSIONIDs. When I remove jboss form apache configuration still not working. Browser still showing two JSESSIONIDs. After clearing cookies in browser cluster is working fine. so what is the reason not to work cluster with jboss ?

Clustering (Apache 2.2.25 mod_jk + JBoss EAP 6.2) with Session Replication OFF and stickiness ON does not work

I am using JBoss EAP 6.2 and Apache 2.2.25-no-ssl for load balancing and clustering deployment of my application.
I want Session Replication off and Sticky session on.
But after doing all sort of configurations, what I noticed that my load balancer not sticking user request based on session-id to one particular node, instead forwarding request to another node.
Below are my cluster configurations.
No of cluster nodes = 2
Apache Load balancer = Apache 2.2.25-no-ssl
App server = JBoss EAP 6.2.0
Apache Load Balancer configuration
workers.properties
# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=172.20.150.33
worker.node1.type=ajp13
worker.node1.ping_mode=A
worker.node1.lbfactor=1
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8209
worker.node2.host=172.20.150.33
worker.node2.type=ajp13
worker.node2.ping_mode=A
worker.node2.lbfactor=1
# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
# Status worker for managing load balancer
worker.status.type=status
uriworkermap.properties
# Simple worker configuration file
# Mount the Servlet context to the ajp13 worker
/*=loadbalancer
mod-jk.conf
# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
# The default setting only sends Java application data to mod_jk.
# Use the commented-out line to send all URLs through mod_jk.
# JkMount /* loadbalancer
JkMount /* loadbalancer
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm
# You can 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/uriworkermap.properties
# Add jkstatus for managing runtime data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
mod-jk.conf loaded in httpd.conf file and Apache runs on port 80.
In JBoss EAP, create two replica named node1 and node2 of standalone folder on same machine as depicted below
Command to start server :
node1
standalone.bat -c standalone-ha.xml -b 172.20.150.33 -u 230.0.10.0 -Djboss.server.base.dir=../node1 -Djboss.node.name=node1 -Dlogging.configuration=file:/${JBOSS_HOME}/node1/configuration/logging.properties
node2
standalone.bat -c standalone-ha.xml -b 172.20.150.33 -u 230.0.10.0 -Djboss.server.base.dir=../node2 -Djboss.node.name=node2 -Dlogging.configuration=file:/${JBOSS_HOME}/node2/configuration/logging.properties -Djboss.socket.binding.port-offset=200
I tried with Session Replication On (by adding in web.xml) but still same problem exists.
Below are my JSESSIONID observations.
on first request
JSESSIONID = SY1d0wVTmX2b-czp50whdmCW.61423f3f-b623-3da4-bd2f-69ba448af636 where 61423f3f-b623-3da4-bd2f-69ba448af636 is JVM-ROUTE for node2.
on second request
JSESSIONID = QMTCTAzt2u-ANTidqZdBIzxO.f742b8d4-46f7-3914-86bb-1044d0a1bfce where f742b8d4-46f7-3914-86bb-1044d0a1bfce is a JVM-ROUTE for node1.
It seems even though jvm-route is appended to primary session id , still load balancer(apache mod-jk) sending request to other node instead of sticking to one on which session established.
Please do helpful.
For this kind of scenario you need to implement this architecture. We are using the same architecture to host Wildfly
Note: Please do not forget to enable session stickiness/connection persistency on Load Balancer(LB) and Apache mod_jk.
In this architecture:
For
WEB1 -> App1 is Active APP NODE
WEB2 -> APP2 is Active APP NODE
So if request/connection comes ON LB it is redirected to WEB1. As session stickiness/connection persistency is enabled on LB All requests coming from the same client are redirected to WEB1 only.
Here is my Apache Load Balancer configuration:
workers.properties For node1
# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=10.62.147.58
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.socket_timeout=600
#worker.node1.ping_timeout=1000
worker.node1.ping_mode=A
#worker.node1.connection_pool_timeout=600
worker.node1.redirect=node2
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=10.62.147.59
worker.node2.type=ajp13
worker.node2.lbfactor=1
#worker.node2.socket_timeout=600
#worker.node2.ping_timeout=1000
worker.node2.ping_mode=A
#worker.node2.connection_pool_timeout=600
worker.node2.activation=disabled
# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
worker.loadbalancer.retry_interval=30
worker.loadbalancer.recover_time=20
#worker.loadbalancer.sticky_session_force=1
# Status worker for managing load balancer
worker.status.type=status
workers.properties For node2
# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=10.62.147.58
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.socket_timeout=600
#worker.node1.ping_timeout=1000
worker.node1.ping_mode=A
#worker.node1.connection_pool_timeout=600
worker.node1.activation=disabled
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=10.62.147.59
worker.node2.type=ajp13
worker.node2.lbfactor=1
#worker.node2.socket_timeout=600
#worker.node2.ping_timeout=1000
worker.node2.ping_mode=A
#worker.node2.connection_pool_timeout=600
worker.node2.redirect=node1
# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
worker.loadbalancer.retry_interval=30
worker.loadbalancer.recover_time=20
#worker.loadbalancer.sticky_session_force=1
# Status worker for managing load balancer
worker.status.type=status
mod-jk.conf
# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
# Notes:
# 1) Changed from +ForwardURICompat.
# 2) For mod_rewrite compatibility, use +ForwardURIProxy (default since 1.2.24)
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories +ForwardURIProxy +ForwardURICompat
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
#JkMount /__application__/* loadbalancer
# Let Apache serve the images
#JkUnMount /__application__/images/* loadbalancer
# You can 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/uriworkermap.properties
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile run/jk.shm
JkMount /* loadbalancer
# Add jkstatus for managing runtime data
<Location /jkstatus>
JkMount status
Order deny,allow
Deny from none
Allow from All
</Location>

Not able to configure mod_JK in HTTPD.CONF file for load balancing

I am not able to configure the apache load balancer with mod_jk. Each time I channge httpd.conf file apache server doesnot start.
Here is the scenario:
I have 2 apache tomcat instance, Tomcat and tomcat2 and both are running on different ports.
I would like to establish a load balancer for these two instances with apache mod_jk:
I have downloded mod_jk.so file and places in modules folder.
Below configuration I am trying to httpd.conf file:
LoadModule jk_module modules/mod_jk.so
AddModule mod_jk.c
JkWorkersFile conf/workers.properties
JkLogFile log/httpd/mod_jk.log
JkLogLevel info
mod_jk loadbalancer
JkMount /examples/* loadbalancer
Here is my workers.propertise file:
# Define list of workers that will be used
worker.list=loadbalancer
# Define Node1
worker.node1.port=8009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10
# Define Node2
worker.node2.port=8010
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.cachesize=10
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
# Status worker for managing load balancer
worker.status.type=status
I am not sure, what is wrong here. May be I am adding the mod_jk conf in httpd.conf file at wrong place.
Can anybody guide. Any sample working HTTPD.CONF file will be great.
Thanks you for the help.
-Santosh
Issue resolve:
I was using the mod_jk.so file compatible with apache version 2.0 and Apache webserver 2.2.
I have downloaded the mod_jk.so file compatible for 2.2 version and now everything is working fine.
You can check detailed error by option:
c:/your_apache_dir/bin> httpd.exe -D mod_jk
Thanks for your help.
JkWorkersFile "conf/workers.properties" this should be this way and also do check for the mod_jk compatibility.

Sticky Session in apache doesn't work

This is currently my environment setup.
Apache Tomcat: Apache-Tomacat-7.0.21
Apache HTTP Server: c. Apache HTTP Server 2.2.19
Tomcat Connector JK 1.2.32 for Apache HTTP Server 2, mod_jk
I'm trying to implement sticky session but i still can't get it to work. I'm able to load balance between 2 machines in a cluster. Please advise what else i have missed out!
Following is my workers.properties file
# Define 2 real workers using ajp13 & 1 balancer
worker.list=balancer
#
worker.balancer.type=lb
worker.balancer.balance_workers=worker1,worker2
worker.balancer.sticky_session=True
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.recycle_timeout=300
# Set properties for worker2 (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=X.X.X.X
worker.worker2.port=8009
worker.worker2.lbfactor=50
worker.worker2.cachesize=10
worker.worker2.cache_timeout=600
worker.worker2.socket_keepalive=1
worker.worker2.recycle_timeout=300
I've also set the jvmRoute in server.xml to:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">