We have an existing setup as below,
1 apache server and 2 tomcat servers in the backend , both the tomcat servers have same application and apache is integrated with these tomcat servers using mod_jk. Everything is working fine.
New requirement to use same apache server to integrate with another set of 2 tomcat servers with different application.
My existing setup looks like below,
Vhost file for app1
<VirtualHost *:80>
RewriteEngine on
RewriteRule (.*) https://%{HTTP_HOST}$1
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
ServerName server.domain.com
ServerAlias *.domain.com
RewriteEngine on
RewriteRule ^/hmc - [F]
RewriteRule ^/hmc_junit - [F]
RewriteRule ^/hac - [F]
RewriteRule ^/hac_junit - [F]
RewriteRule ^/rest - [F]
RewriteRule ^/backoffice - [F]
RewriteRule ^/admincockpit - [F]
RewriteRule ^/cmscockpit - [F]
Header always set Strict-Transport-Security "max-age=63072000;"
# Header always set X-Frame-Options DENY
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
RequestHeader set X-Forwarded-Proto https
LogLevel warn
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
JkMount app1/* loadbalancer
JkMount /status node1
</VirtualHost>
Vhost file for app2
<VirtualHost *:80>
RewriteEngine on
RewriteRule (.*) https://%{HTTP_HOST}$1
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
ServerName server.domain.com
ServerAlias *.domain.com
RewriteEngine on
RewriteRule ^/hmc - [F]
RewriteRule ^/hmc_junit - [F]
RewriteRule ^/hac - [F]
RewriteRule ^/hac_junit - [F]
RewriteRule ^/rest - [F]
RewriteRule ^/backoffice - [F]
RewriteRule ^/admincockpit - [F]
RewriteRule ^/cmscockpit - [F]
Header always set Strict-Transport-Security "max-age=63072000;"
# Header always set X-Frame-Options DENY
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
RequestHeader set X-Forwarded-Proto https
LogLevel warn
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
JkMount app2/* loadbalancer2
JkMount /status node3
</VirtualHost>
mod_jk.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount app1/* loadbalancer
JkMount app2/* loadbalancer2
JkShmFile logs/jk.shm
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from all
</Location>
workers.properties
#Define list of workers that will be used
# for mapping requests
workers.list=loadbalancer,loadbalancer2,status
# Define Node1
modify the host as your host IP or DNS name.
workers.node1.port=8009
workers.node1.host=tomcat1.domain.com
workers.node1.type=ajp13
workers.node1.ping_mode=A
workers.node1.lbfactor=1
#Define Node2
modify the host as your host IP or DNS name.
workers.node2.port=8009
workers.node2.host=tomcat2.domain.com
workers.node2.type=ajp13
workers.node2.ping_mode=A
workers.node2.lbfactor=1
# Define Node3
# modify the host as your host IP or DNS name.
workers.node3.port=8009
workers.node3.host=tomcat3.domain.com
workers.node3.type=ajp13
workers.node3.ping_mode=A
workers.node3.lbfactor=1
# Define Node4
# modify the host as your host IP or DNS name.
workers.node4.port=8009
workers.node4.host=tomcat4.domain.com
workers.node4.type=ajp13
workers.node4.ping_mode=A
workers.node4.lbfactor=1
# Load-balancing behavior
workers.loadbalancer.type=lb
workers.loadbalancer.balance_workers=node1,node2
workers.loadbalancer.sticky_session=1
# Load-balancing behavior
workers.loadbalancer2.type=lb
workers.loadbalancer2.balance_workers=node3,node4
workers.loadbalancer2.sticky_session=1
# Status worker for managing load balancer
workers.status.type=status
But , to add 2 new tomcat serves (for second application) in apache . i've created another workers.properties file , modjk.conf and another vhost file .and tried restarting the apache and failed with below error. Apache is considering JkWorkersFile in second modjk.conf as duplicate.
How to fix this issue and use same apache for integrating different tomcat servers (diff apps) ?
Thank you in advance.
Sep 01 18:20:29 l6681t.sss.se.scania.com systemd[1]: Starting The Apache HTTP Server...
Sep 01 18:20:29 l6681t.sss.se.scania.com httpd[2743]: AH00526: Syntax error on line 6 of /etc/httpd/conf.d/qa02-modjk.conf:
Sep 01 18:20:29 l6681t.sss.se.scania.com httpd[2743]: JkWorkersFile only allowed once
Sep 01 18:20:29 l6681t.sss.se.scania.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Sep 01 18:20:29 l6681t.sss.se.scania.com systemd[1]: Failed to start The Apache HTTP Server.
Sep 01 18:20:29 l6681t.sss.se.scania.com systemd[1]: Unit httpd.service entered failed state.
Sep 01 18:20:29 l6681t.sss.se.scania.com systemd[1]: httpd.service failed.