Saturday, February 5, 2022

RHEL based HTTP (httpd-2.2.15-69.el6.x86_64)and mod_jk modules cohesion with Jboss EAP 7

 Contents

RHEL based HTTP (httpd-2.2.15-69.el6.x86_64)and mod_jk modules cohesion with Jboss EAP 7

OS details:

Pre-installed RPMs:

Download tomcat-connectors-1.2.48-src.tar.gz from opensource site:

Cooking mod_jk mdules:

Extract source code:

Before proceeding further let’s learn about “configure”, “make” and “make install”:

Building and installing mod_jk modles:

Step 1: Configure sourceCode mod_jk:

Step 2: Build mod_jk module:

Step 3: Installing mod_jk module:

Creating HTTP configuration files using mod_jk module:

Lets create mod_jk configuration file “/etc/httpd/conf.d/srilab-mod-jk.conf”:

Now time to create HTTP worker “/etc/httpd/conf/srilabworkers.properties“ configuration is responsible to tell mod_jk about backend JVMs and route details:

Let’s learn something AJP:

Let’s learn about HTTP log code:

Back to lab, let’s test our configuration see entries made are right, good and are working:

Time to restart HTTP & check load balancer:

Let’s test application URL and its load balancer routes:

RHEL based HTTP (httpd-2.2.15-69.el6.x86_64)and mod_jk modules cohesion with Jboss EAP 7

 

OS details:

 

[jadm@lab1 ~]$ uname -a ; cat /etc/redhat-release

Linux lab1.sri.com 2.6.32-754.el6.x86_64 #1 SMP Thu May 24 18:18:25 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux

Red Hat Enterprise Linux Server release 6.10 (Santiago)

[jadm@lab1 ~]$

 

Pre-installed RPMs:

 

httpd-2.2.15-69.el6.x86_64

httpd-tools-2.2.15-69.el6.x86_64

httpd-devel-2.2.15-69.el6.x86_64

gcc-4.4.7-23.el6.x86_64

libgcc-4.4.7-23.el6.x86_64

libtool-ltdl-2.2.6-15.5.el6.x86_64

 

[jadm@lab1 MOD_JK]$ rpm -qi httpd-2.2.15-69.el6.x86_64

Name        : httpd                        Relocations: (not relocatable)

Version     : 2.2.15                            Vendor: Red Hat, Inc.

Release     : 69.el6                        Build Date: Mon 19 Feb 2018 05:04:20 PM IST

Install Date: Fri 14 Jan 2022 05:52:54 PM IST      Build Host: x86-027.build.eng.bos.redhat.com

Group       : System Environment/Daemons    Source RPM: httpd-2.2.15-69.el6.src.rpm

Size        : 3165442                          License: ASL 2.0

Signature   : RSA/8, Mon 19 Feb 2018 09:16:15 PM IST, Key ID 199e2f91fd431d51

Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>

URL         : http://httpd.apache.org/

Summary     : Apache HTTP Server

Description :

The Apache HTTP Server is a powerful, efficient, and extensible

web server.

[jadm@lab1 MOD_JK]$

 

Download tomcat-connectors-1.2.48-src.tar.gz from opensource site:

http://tomcat.apache.org/download-connectors.cgi

 

Cooking mod_jk mdules.

 

Create directory to extract source code:

 

[jadm@lab1 ~]$ cd /lab/APACHEhttpd/

[jadm@lab1 APACHEhttpd]$

[jadm@lab1 APACHEhttpd]$ mkdir MOD_JK

[jadm@lab1 APACHEhttpd]$ cd MOD_JK/

[jadm@lab1 MOD_JK]$

[jadm@lab1 MOD_JK]$ pwd

/lab/APACHEhttpd/MOD_JK

[jadm@lab1 MOD_JK]$

 

Extract source code:

 

[jadm@lab1 MOD_JK]$ tar -zxvf /lab/WAS70/fileRegistry/packages/tomcat-connectors-1.2.48-src.tar.gz

tomcat-connectors-1.2.48-src/

tomcat-connectors-1.2.48-src/docs/ajp/printer/ajpv13ext.html

tomcat-connectors-1.2.48-src/docs/ajp/ajpv13ext.html

.

.

[jadm@lab1 MOD_JK]$

 

[jadm@lab1 MOD_JK]$ cd tomcat-connectors-1.2.48-src/

[jadm@lab1 tomcat-connectors-1.2.48-src]$ ll

total 60

drwxr-xr-x.  2 jadm jadm  4096 Feb 20  2020 conf

drwxr-xr-x. 10 jadm jadm  4096 Feb 20  2020 docs

-rw-r--r--.  1 jadm jadm  7274 Feb 20  2020 HOWTO-RELEASE.txt

drwxr-xr-x.  6 jadm jadm  4096 Feb 20  2020 jkstatus

-rw-r--r--.  1 jadm jadm 13597 Feb 20  2020 LICENSE

drwxr-xr-x.  8 jadm jadm  4096 Feb 20  2020 native

-rw-r--r--.  1 jadm jadm   455 Feb 20  2020 NOTICE

-rw-r--r--.  1 jadm jadm  1238 Feb 20  2020 README.txt

drwxr-xr-x.  2 jadm jadm  4096 Feb 20  2020 support

drwxr-xr-x.  4 jadm jadm  4096 Feb 20  2020 tools

drwxr-xr-x.  9 jadm jadm  4096 Feb 20  2020 xdocs

[jadm@lab1 tomcat-connectors-1.2.48-src]$

 

Before proceeding further let’s learn about “configure”, “make” and “make install”

 

The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available and finds out whatever it needs to know to use those dependencies.

Once configure has done its job, we can invoke make to build the software. This runs a series of tasks defined in a Makefile to build the finished program from its source code.

Now that the software is built and ready to run, the files can be copied to their final destinations. The make install command will copy the built program, and its libraries and documentation, to the correct locations.

 

Building and installing mod_jk modles:

 

Step 1: Configure sourceCode mod_jk:

 

[jadm@lab1 native]$ sh configure --with-apxs=/usr/sbin/apxs

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking target system type... x86_64-pc-linux-gnu

.

.

config.status: executing depfiles commands

config.status: executing libtool commands

[jadm@lab1 native]$

 

 

[jadm@lab1 native]$

 

Step 2: Build mod_jk module:

 

[jadm@lab1 native]$ make

Making all in common

.

.

make[1]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native'

target="all"; \

        list='common apache-2.0'; \

        for i in $list; do \

            echo "Making $target in $i"; \

            if test "$i" != "."; then \

               (cd $i && make $target) || exit 1; \

            fi; \

        done;

Making all in common

make[1]: Entering directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/common'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/common'

Making all in apache-2.0

make[1]: Entering directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/apache-2.0'

../scripts/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool --silent' mod_jk.la `pwd`

/usr/lib64/apr-1/build/libtool --silent --mode=install cp mod_jk.la /lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/apache-2.0/

libtool: install: warning: remember to run `libtool --finish /usr/lib64/httpd/modules'

make[1]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/apache-2.0'

[jadm@lab1 native]$

 

Step 3: Installing mod_jk module:

 

[jadm@lab1 native]$ make install

Making install in common

make[1]: Entering directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/common'

make[1]: Nothing to be done for `install'.

make[1]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/common'

Making install in apache-2.0

make[1]: Entering directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/apache-2.0'

 

Installing files to Apache Modules Directory...

/usr/sbin/apxs -i mod_jk.la

/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' mod_jk.la /usr/lib64/httpd/modules

/usr/lib64/apr-1/build/libtool --mode=install cp mod_jk.la /usr/lib64/httpd/modules/

libtool: install: cp .libs/mod_jk.so /usr/lib64/httpd/modules/mod_jk.so

libtool: install: cp .libs/mod_jk.lai /usr/lib64/httpd/modules/mod_jk.la

libtool: install: cp .libs/mod_jk.a /usr/lib64/httpd/modules/mod_jk.a

libtool: install: chmod 644 /usr/lib64/httpd/modules/mod_jk.a

libtool: install: ranlib /usr/lib64/httpd/modules/mod_jk.a

libtool: finish: PATH="/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin:/home/jadm/bin:/sbin" ldconfig -n /usr/lib64/httpd/modules

----------------------------------------------------------------------

Libraries have been installed in:

   /usr/lib64/httpd/modules

 

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

     during execution

   - add LIBDIR to the `LD_RUN_PATH' environment variable

     during linking

   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

 

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

chmod 755 /usr/lib64/httpd/modules/mod_jk.so

 

Please be sure to arrange /etc/httpd/conf/httpd.conf...

 

make[1]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native/apache-2.0'

make[1]: Entering directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native'

make[2]: Entering directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native'

make[2]: Nothing to be done for `install-exec-am'.

make[2]: Nothing to be done for `install-data-am'.

make[2]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native'

make[1]: Leaving directory `/lab/APACHEhttpd/MOD_JK/tomcat-connectors-1.2.48-src/native'

[jadm@lab1 native]$

 

Creating HTTP configuration files using mod_jk module:

 

Default when httpd is started it will read all configuration file ending with extension “.conf” in conf.d from default path of http. Here in this case it will be /etc/httpd/conf.d

 

And following http configurations if responsible for this.

 

[jadm@lab1 MOD_JK]$ grep Include /etc/httpd/conf/httpd.conf | grep -v "#"

Include conf.d/*.conf

        Options IncludesNoExec

        AddOutputFilter Includes html

[jadm@lab1 MOD_JK]$

 

Lets create mod_jk configuration file “/etc/httpd/conf.d/srilab-mod-jk.conf”:

 

Content is self-explanatory –

 

[jadm@lab1 logs]$ cat /etc/httpd/conf.d/srilab-mod-jk.conf

# Load mod_jk module

# Specify the filename of the mod_jk lib

LoadModule jk_module /usr/lib64/httpd/modules/mod_jk.so

 

# Where to find workers.properties

JkWorkersFile conf/srilabworkers.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

JkOptions +ForwardKeySize -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.

# /* means all URIs will be sent or directed to following load balancer.

JkMount /* srilabloadbalancer

 

# 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

 

# Add jkstatus for managing runtime data

<Location /jkstatus/>

JkMount status

Require all granted

</Location>

[jadm@lab1 logs]$

 

Now time to create HTTP worker “/etc/httpd/conf/srilabworkers.properties“ configuration is responsible to tell mod_jk about backend JVMs and route details:

 

[jadm@lab1 conf.d]$ cat /etc/httpd/conf/srilabworkers.properties

# Define list of workers that will be used

# for mapping requests

worker.list=srilabloadbalancer,status

 

# Define JVM1

# modify the host as your host IP or DNS name.

worker.srilabjvm1.port=8109

worker.srilabjvm1.host=lab2.sri.com

worker.srilabjvm1.type=ajp13

worker.srilabjvm1.ping_mode=A

worker.srilabjvm1.lbfactor=1

 

# Define JVM2

# modify the host as your host IP or DNS name.

worker.srilabjvm2.port=8209

worker.srilabjvm2.host=lab2.sri.com

worker.srilabjvm2.type=ajp13

worker.srilabjvm2.ping_mode=A

worker.srilabjvm2.lbfactor=1

 

# Load-balancing behavior

worker.srilabloadbalancer.type=lb

worker.srilabloadbalancer.balance_workers=srilabjvm1,srilabjvm2

worker.srilabloadbalancer.sticky_session=1

 

# Status worker for managing load balancer

worker.status.type=status

[jadm@lab1 conf.d]$

 

In above example I have 2 JVMs running in lab2 node with AJP ports 8109 and 8209.

 

Let’s learn something about AJP:

 

The Apache JServ Protocol (AJP) is a method for a web server to communicate with an associated application server. The web server is a "reverse proxy," meaning, its purpose is to handle incoming traffic from the Internet on behalf of the application server.

 

The AJP connectors are child resources of the subsystem web. They are used with mod_jk, mod_proxy and mod_cluster of the Apache httpd front-end.

If you are fronting your app server with a web proxy server, AJP allows you to skip that extra parsing and just pass efficient binary representations of the headers between the proxy server and the app server. There are other benefits with things like simple connection pools and tight integration if you use apache/mod_jk

AJP runs in Apache HTTP Server 1.x using the mod_jk plugin and in Apache 2.x using the provided Proxy AJP, mod_proxy and proxy balancer modules together.

AJP Connectors work in the same way as HTTP Connectors, but they use the AJP protocol in place of HTTP. Apache JServ Protocol, or AJP, is an optimized binary version of HTTP that is typically used to allow Tomcat to communicate with an Apache web server.

 

The http protocol is quite expensive in terms of band width - it's an ascii text protocl with words like "POST" and phrases like "Content-type:" taking up more bandwidth than is really needed, and having to be interpreted at destination too. So the ajp protocol (Apache Java Protocol?) was established to allow for much less expensive exchanges between upstream and downstream servers that are to be closely linked. ajp carries the same information as http but in a binary format. The request method - GET or POST - is reduced to a single byte, and each of the additional headers are reduced to 2 bytes - typically, that's about a fifth of the size of the http packet.

 

Features

Web traffic is carried out in HTTP (Hypertext Transfer Protocol), which also carries through to communication between servers working together to fulfill a request. HTTP is a plain-text format where actual words make up the messages running between computers. This create an overhead of traffic. AJP converts these messages into a binary code, reducing the amount of space taken by each message.

 

Function

Speed between collaborating servers is a distinctive feature of the protocol. The process maintains permanent connections between servers to reduce the time taken to establish contact. The link is dedicated to a particular request and then maintained for the next request to be tunneled down, rather than each session causing a session to be created and broken.

 

Implementation

AJP is particularly used for "Load Balancing." This is where one server distributes incoming traffic among several application servers, sharing the load equally.

 

Let’s learn about HTTP log code:

 

A server processes an http request and sends out a response. The response comprises a header block, a blank line, and (in most cases) a data block. The first line of the header includes a response code which indicates the success or otherwise of the request - a 3 digit number in the following ranges:

200 and up - success; expect good data to follow

300 and up - good request but only headers (no data). e.g. page has moved

400 and up - error in request. e.g. request was for missing page (404)

500 and up - error in handling request. e.g. program on server has syntax error

 

Back to lab, let’s test our configuration see entries made are right, good and are working.

 

[jadm@lab1 conf.d]$ httpd -M -f /etc/httpd/conf/httpd.conf | grep jk

 jk_module (shared)

Syntax OK

[jadm@lab1 conf.d]$

 

[jadm@lab1 conf.d]$ httpd -M -f /etc/httpd/conf/httpd.conf

Loaded Modules:

 core_module (static)

 mpm_prefork_module (static)

 http_module (static)

 so_module (static)

 auth_basic_module (shared)

 auth_digest_module (shared)

 authn_file_module (shared)

 authn_alias_module (shared)

 authn_anon_module (shared)

 authn_dbm_module (shared)

 authn_default_module (shared)

 authz_host_module (shared)

 authz_user_module (shared)

 authz_owner_module (shared)

 authz_groupfile_module (shared)

 authz_dbm_module (shared)

 authz_default_module (shared)

 ldap_module (shared)

 authnz_ldap_module (shared)

 include_module (shared)

 log_config_module (shared)

 logio_module (shared)

 env_module (shared)

 ext_filter_module (shared)

 mime_magic_module (shared)

 expires_module (shared)

 deflate_module (shared)

 headers_module (shared)

 usertrack_module (shared)

 setenvif_module (shared)

 mime_module (shared)

 dav_module (shared)

 status_module (shared)

 autoindex_module (shared)

 info_module (shared)

 dav_fs_module (shared)

 vhost_alias_module (shared)

 negotiation_module (shared)

 dir_module (shared)

 actions_module (shared)

 speling_module (shared)

 userdir_module (shared)

 alias_module (shared)

 substitute_module (shared)

 rewrite_module (shared)

 proxy_module (shared)

 proxy_balancer_module (shared)

 proxy_ftp_module (shared)

 proxy_http_module (shared)

 proxy_ajp_module (shared)

 proxy_connect_module (shared)

 cache_module (shared)

 suexec_module (shared)

 disk_cache_module (shared)

 cgi_module (shared)

 version_module (shared)

 jk_module (shared)

 ssl_module (shared)

Syntax OK

[jadm@lab1 conf.d]$

 

Time to restart HTTP & check load balancer:

 

[jadm@lab1 conf.d]$ httpd -f /etc/httpd/conf/httpd.conf -k stop

 

[jadm@lab1 conf.d]$ httpd -f /etc/httpd/conf/httpd.conf -k start

 

[jadm@lab1 logs]$ tailf mod_jk.log

[Sun Jan 16 16:01:51 2022][6900:140199872554976] [info] init_jk::mod_jk.c (3591): mod_jk/1.2.48 initialized

[Sun Jan 16 16:01:51 2022][6901:140199872554976] [info] init_jk::mod_jk.c (3591): mod_jk/1.2.48 initialized

[Sun Jan 16 16:03:29 2022]srilabloadbalancer 192.168.100.151 3.588895

[Sun Jan 16 16:03:29 2022]srilabloadbalancer 192.168.100.151 0.309377

[Sun Jan 16 16:03:49 2022]srilabloadbalancer 192.168.100.151 0.417934

[Sun Jan 16 16:03:56 2022]srilabloadbalancer 192.168.100.151 1.839835

[Sun Jan 16 16:03:57 2022]srilabloadbalancer 192.168.100.151 0.020268

[Sun Jan 16 16:03:58 2022]srilabloadbalancer 192.168.100.151 0.021093

[Sun Jan 16 16:03:59 2022]srilabloadbalancer 192.168.100.151 0.017189

[Sun Jan 16 16:04:00 2022]srilabloadbalancer 192.168.100.151 0.023566

[Sun Jan 16 16:04:01 2022]srilabloadbalancer 192.168.100.151 0.018578

[Sun Jan 16 16:04:01 2022]srilabloadbalancer 192.168.100.151 0.007520

[Sun Jan 16 16:04:02 2022]srilabloadbalancer 192.168.100.151 0.025920

[Sun Jan 16 16:04:03 2022]srilabloadbalancer 192.168.100.151 0.008294

[Sun Jan 16 16:04:03 2022]srilabloadbalancer 192.168.100.151 0.018125

[Sun Jan 16 16:04:04 2022]srilabloadbalancer 192.168.100.151 0.009754

[Sun Jan 16 16:04:04 2022]srilabloadbalancer 192.168.100.151 0.038516

^C

[jadm@lab1 logs]$

 

Let’s test application URL and its load balancer routes:

 

[jadm@lab1 logs]$ elinks --dump http://192.168.100.151:8008/Sricluster-testEAP6v1.1/sessionTest.jsp

   welcome to Sri NGEN LABs world!!!!!

 

 

   The sessionId is:         F5bRkZYMT0jS5up4mU-vzOxRJ0pU0bW2WGKIqivp

   The sessionObj is:        io.undertow.servlet.spec.HttpSessionImpl@4ab3803

   The nodeId is:            lab2jvm1

   The server hostName is:   lab2

   The server hostOSname is: Linux

   The server hostOSarch is: amd64

   The server hostOSversion  2.6.32-754.el6.x86_64

   is:

   The server                1.8.0_171

   hostJAVAversion is:

   The server hostJAVAvendor Oracle Corporation

   is:

   The server hostJAVAvmName OpenJDK 64-Bit Server VM

   is:

   The server                25.171-b10

   hostJAVAvmVersion is:

   The server                Oracle Corporation

   hostJAVAvmVendor is:

   # of requests placed on   0

   session:

[jadm@lab1 logs]$ elinks --dump http://192.168.100.151:8008/Sricluster-testEAP6v1.1/sessionTest.jsp

   welcome to Sri NGEN LABs world!!!!!

 

 

   The sessionId is:        0UchOhKS_YoOrdkB0YiwdR5wfeYTImNund5HKepG

   The sessionObj is:       io.undertow.servlet.spec.HttpSessionImpl@946a7454

   The nodeId is:           lab2jvm2

   The server hostName is:  lab2

   The server hostOSname    Linux

   is:

   The server hostOSarch    amd64

   is:

   The server hostOSversion 2.6.32-754.el6.x86_64

   is:

   The server               1.8.0_171

   hostJAVAversion is:

   The server               Oracle Corporation

   hostJAVAvendor is:

   The server               OpenJDK 64-Bit Server VM

   hostJAVAvmName is:

   The server               25.171-b10

   hostJAVAvmVersion is:

   The server               Oracle Corporation

   hostJAVAvmVendor is:

   # of requests placed on  0

   session:

[jadm@lab1 logs]$