2014-05-05 19:58:51 +01:00
|
|
|
{ config, pkgs, serverInfo, lib, ... }:
|
2009-01-16 14:07:54 +00:00
|
|
|
|
|
|
|
let
|
2014-05-05 19:58:51 +01:00
|
|
|
extraWorkersProperties = lib.optionalString (config ? extraWorkersProperties) config.extraWorkersProperties;
|
2012-02-06 13:11:48 +00:00
|
|
|
|
2009-01-16 14:07:54 +00:00
|
|
|
workersProperties = pkgs.writeText "workers.properties" ''
|
|
|
|
# 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=localhost
|
|
|
|
worker.node1.type=ajp13
|
|
|
|
worker.node1.lbfactor=1
|
|
|
|
|
|
|
|
# Load-balancing behaviour
|
|
|
|
worker.loadbalancer.type=lb
|
|
|
|
worker.loadbalancer.balance_workers=node1
|
|
|
|
|
|
|
|
# Status worker for managing load balancer
|
|
|
|
worker.status.type=status
|
2012-02-06 13:11:48 +00:00
|
|
|
|
|
|
|
${extraWorkersProperties}
|
2009-01-16 14:07:54 +00:00
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
2014-07-31 15:51:51 +01:00
|
|
|
|
|
|
|
options = {
|
2014-08-01 21:23:56 +01:00
|
|
|
extraWorkersProperties = lib.mkOption {
|
2014-07-31 15:51:51 +01:00
|
|
|
default = "";
|
|
|
|
description = "Additional configuration for the workers.properties file.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-01-16 14:07:54 +00:00
|
|
|
extraModules = [
|
|
|
|
{ name = "jk"; path = "${pkgs.tomcat_connectors}/modules/mod_jk.so"; }
|
|
|
|
];
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
# Where to find workers.properties
|
|
|
|
JkWorkersFile ${workersProperties}
|
|
|
|
|
|
|
|
# Where to put jk logs
|
2013-10-29 00:26:51 +00:00
|
|
|
JkLogFile ${serverInfo.serverConfig.logDir}/mod_jk.log
|
2009-01-16 14:07:54 +00:00
|
|
|
|
|
|
|
# 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
|
2011-09-14 19:20:50 +01:00
|
|
|
# Note: Changed from +ForwardURICompat.
|
|
|
|
# See http://tomcat.apache.org/security-jk.html
|
2009-01-16 14:07:54 +00:00
|
|
|
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
|
|
|
|
|
|
|
|
# JkRequestLogFormat
|
|
|
|
JkRequestLogFormat "%w %V %T"
|
|
|
|
|
|
|
|
# Mount your applications
|
|
|
|
JkMount /__application__/* 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 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
|
2011-09-14 19:20:50 +01:00
|
|
|
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
|
2009-01-16 14:07:54 +00:00
|
|
|
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
|
2013-10-29 00:26:51 +00:00
|
|
|
JkShmFile ${serverInfo.serverConfig.stateDir}/jk.shm
|
2009-01-16 14:07:54 +00:00
|
|
|
|
|
|
|
# Static files in all Tomcat webapp context directories are served by apache
|
|
|
|
JkAutoAlias /var/tomcat/webapps
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-01-16 14:07:54 +00:00
|
|
|
# All requests go to worker by default
|
|
|
|
JkMount /* loadbalancer
|
|
|
|
# Serve some static files using httpd
|
2009-01-27 13:02:56 +00:00
|
|
|
#JkUnMount /*.html loadbalancer
|
|
|
|
#JkUnMount /*.jpg loadbalancer
|
|
|
|
#JkUnMount /*.gif loadbalancer
|
|
|
|
#JkUnMount /*.css loadbalancer
|
|
|
|
#JkUnMount /*.png loadbalancer
|
|
|
|
#JkUnMount /*.js loadbalancer
|
2009-01-16 14:07:54 +00:00
|
|
|
|
|
|
|
# Add jkstatus for managing runtime data
|
|
|
|
<Location /jkstatus/>
|
|
|
|
JkMount status
|
|
|
|
Order deny,allow
|
|
|
|
Deny from all
|
|
|
|
Allow from 127.0.0.1
|
|
|
|
</Location>
|
|
|
|
'';
|
|
|
|
}
|