Search code examples
mod-jksap-commerce-cloud

mod_jk hybris loadbalancer


I have two apache 2.4 web servers and 2 hybris 5.7.3 appservers. I decided to configure mod_jk 1.2.41 in both web servers with app server loadbalancing. Appservers will run on https only, Can you anyone help me to configure mod_jk for hybris.

Thanks you @Benoit for quick respone. Here is the configuration:

httpd.conf file

LoadModule jk_module /usr/lib64/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/httpd/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 indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

    <VirtualHost *>
      ServerAlias www.thaitrade.dev
      DocumentRoot /var/www
      ServerName webserverurl
      JkMount /* loadbalancer
      JkMount /status/* status
    </VirtualHost>

updated workers.properties config

 # workers to contact, that's what you have in your httpd.conf
    worker.list=loadbalancer,status

    #setup node1
    worker.worker1.port=8009
    worker.worker1.host=hybrisserver1.ip
    worker.worker1.type=ajp13
    worker.worker1.lbfactor=50

    #setup node2
    worker.worker2.port=8009
    worker.worker2.host=hybrisserver2.ip
    worker.worker2.type=ajp13
    worker.worker2.lbfactor=100

    #setup the load-balancer
    worker.loadbalancer.type=lb
    worker.loadbalancer.balance_workers=worker1,worker2
    worker.loadbalancer.sticky_session=True
    #worker.loadbalancer.sticky_session_force=True

    # Status worker for managing load balancer
    worker.status.type=status

and added jvmRoute to server.xml in hybrisserver1

 <Engine name="Catalina" defaultHost="localhost"  jvmRoute="worker1">

added jvmRoute to server.xml in hybrisserver2

<Engine name="Catalina" defaultHost="localhost"  jvmRoute="worker2">

I additionally added below config to server.xml

 <Connector protocol="AJP/1.3" port="8010" proxyPort="443" scheme="https" secure="true" />

created a new ssl virtualhost config

    Listen 443 https

    <VirtualHost *:443>
    SSLEngine on
    JkMountCopy On
    SSLCertificateFile  /etc/httpd/conf.d/certificate.crt
    SSLCertificateKeyFile  /etc/httpd/conf.d/certificate.key
     </VirtualHost>

Below are mod_jk errors

   [Wed Apr 13 19:29:24 2016] [17689:140131769874496] [debug] jk_translate::mod_jk.c (3855): missing uri map for webservername:/hmc
    [Wed Apr 13 19:29:24 2016] [17689:140131769874496] [debug] jk_map_to_storage::mod_jk.c (4023): missing uri map for webservername:/hmc
    [Wed Apr 13 19:29:25 2016] [17826:140131769874496] [debug] jk_child_init::mod_jk.c (3474): Initialized mod_jk/1.2.41
    [Wed Apr 13 19:29:27 2016] [17689:140131769874496] [debug] jk_translate::mod_jk.c (3855): missing uri map for webservername:/hac
    [Wed Apr 13 19:29:27 2016] [17689:140131769874496] [debug] jk_map_to_storage::mod_jk.c (4023): missing uri map for webservername:/hac

that's my configuration. I didnt received ssl certificates. for time being i will generate self signed certificates and can you please guide me how to add ssl certificates to mod_jk configuration and also do i need to add new worker and worker port in workers.properties file?


Solution

  • Hi @BenoitVanalderweireldt, removed proxyport and added jvmRoute in server.xml and also added x-forwarded-proto in ssl configuration. that's it, the configuration is working now. Thanks for your wonderful support