Apache TomcatApache Logo

The Apache Tomcat Connector - Reference Guide configuration


The forwarding of requests from the web server to tomcat gets configured by defining mapping rules. Such a rule maps requests to workers. The request part of the map is described by a URI pattern, the worker by it's worker name.

The so-called uriworkermap file is a mechanism of defining rules, which works for all web servers. There exist also other web server specific configuration options for defining rules, which will be mostly discussed on the reference pages for configuring tomcat connectors for the individual web servers.

The name of the file is usually, although this is configurable in the web server. Please consult the web server specific documentation pages on how to enable the uriworkermap file.

The main features supported by the uriworkermap file are

  • Exact and wildchar matches, shortcuts to map a directory and all including content.
  • Exclusion rules, disabling of rules an defined preferences behaviour.
  • Virtual host integration: uri mapping rules can be expressed per virtual host. The details are web server specific though.
  • Dynamic reloading: The file gets checked periodically for changes. New versions are automatically reloaded without web server restarts.
  • Integration with the status worker.
  • Support for comments in the rule file.
The following sections describe these aspects in more detail.


Line format

The file has a line based format. There are no continuation characters, so each rule needs to be defined on a single line. Each rule is a pair consisting of a URI pattern and a worker name, combined by an equals sign '=':

The URI pattern is case sensitive.

Comments, white space

All text after and including the character '#' gets ignored and can be used for comments. Leading and trailing white space gets trimmed around the URI pattern and also around the worker name. The following definitions are all equivalent:

  # This is a white space example
  /myapp  =  myworker

URI patterns

Inside the URI pattern three special characters can be used, '*', '?' and '|'. The character '*' is a wildchar that matches any number of arbitrary characters in the URI, '?' matches exactly one character. Each URI pattern has to start with the character '/', or with '*' or with '?', optionally prefixed by any combination of the modifiers '!' and '-' (see next section).

  # Mapping the URI /myapp1 and everything under /myapp1/:
  # Mapping all URI which end with a common suffix:
Since the first case of mapping a certain location and everything inside it is very common, the character '|' gives a handy shortcut:
  # Mapping the URI /myapp1 and everything under /myapp1/:
The pattern 'X|Y' is exactly equivalent to the two maps 'X' and 'XY'.

Exclusion, Disabling and Preferences

Exclusions and rule disabling

Exclusion rules allows to define exclusions from URI rules, which would forward requests to tomcat. If the exclusion rule matches, the request will not be forwarded. This is usually used to serve static content by the web server. An rule is an exclusion rule, if it is suffixed with '!':

  # Mapping the URI /myapp and everything under /myapp/:
  # Exclude the subdirectory static:
  # Exclude some suffixes:

Rule disabling comes into play, if your web server merges rules from various sources, and you want to disable any rule defined previously. Since the uriworkermap file gets reloaded dynamically, you can use this to temporarily disable request forwarding: An rule gets disabled, if it is suffixed with '-':

  # We are not in maintenance.
  # The maintenance rule got defined someahere else.
Exclusion rules can get disabled as well, then the rule starts with '-!'.

Mapping preferences

The most restrictive URI pattern is applied first. More precisely the URI patterns are sorted by the number of '/' characters in the pattern (highest number first), and rules with equal numbers are sorted by their string length (longest first).

If both distinctions still do not suffice, then the defining source of the rule is considered. Rules defined in come first, before rules defined by JkMount (Apache) and inside using the mount attribute.

All disabled rules are ignored. Exclusion rules are applied after all normal rules have been applied.

There is no defined behaviour, for the following configuration conflict: using literally the same URI pattern in the same defining source but with different worker targets.

Virtual host integration


When using IIS you can restrict individual rules to special virtual hosts by prefixing the URI pattern with the virtual host information. The rules is that the url must be prefixed with the host name.

  # Use as virtual host
  # Use as virtual host
  # Normal mapping

Note that /mysecondapp/* will be mapped to all virtual hosts present. In case one needs to prevent the mappings to some particular virual host then the exclusion rule must be used

  # Make sure the myapp is accessible by all virtual hosts
  # Disable mapping myapp for virtual host

Apache httpd

For Apache you can define individual uriworkermap files per virtual host. The directive JkMountFile can be used in the main server and in each virtual host. If a virtual host does not use JkMountfile, but JkMountCopy is set to 'On', then it inhertis the JkMountFile from the main server.

Dynamic reloading

When a request is being processed, tomcat connectors check the file modification time of the uriworkermap file. To keep the performance penalty low, this happens only, if the last check happened at least n seconds ago.

For Apache you can configure the interval "n" using the directive JkMountFile, for IIS you would use the attribute worker_mount_reload. The default value is 60 seconds. A value of "0" turns off the reloading.

If the file changed, it gets reloaded completely. If there exist rules coming from other sources than the uriworkermap file (e.g. the mount attribute or JkMount with Apache httpd), the new uriworkermap file gets dynamically merged with these ones exactly like when you do a web server restart.

Until version 1.2.19 reloading behaved slightly differently: it continuously added the full contents of the uriworkermap file to the rule mapping. The merging rules were, that duplicated got eliminated and old rules could be disabled, by defining the rule as disabled in the new file. Rules never got deleted.

Status worker integration

The configuration view of the status worker also shows the various mapping rules. After each worker's configuration, the rules are listed, that forward to this worker. The list contains three columns:

  • the type of the rule: Exact or Wildchar, eventually prefixed with Disabled or Unmount (for exclusion rules)
  • the URI pattern
  • and the source of the rule definition: 'worker definition' for the file (mount attribute), 'JkMount' for Apache httpd JkMount and it's relatives and finally 'uriworkermap' for the uriworkermap file.
For Apache httpd, there is an important subtlety: the request going to the status worker gets executed in the context of some server (main or virtual). The status worker will only show the mapping rules, that are defined for this server (main or virtual).

Copyright © 1999-2005, Apache Software Foundation