Request Tracker with Docker
This is a complete setup for Request Tracker with docker and docker compose. The production setup assumes you have an external postgres database and an external SMTP server for outgoing emails. A local database server is only started in the dev configuration.
The prebuilt image is available from https://hub.docker.com/r/firefart/requesttracker. The image is rebuilt on a daily basis.
The Request Tracker for Incident Response (RT-IR) extension is also installed among various others. Look at the Dockerfile to see the available extensions.
docker based installation
Prerequisites
- Docker with the
compose plugin
- an external SMTP server to send emails
- an external IMAP server to receive emails from
- an external Postgres database
- a host kernel with user namespaces enabled (
user.max_user_namespaces > 0), needed by the Chromium sandbox (see Chromium / seccomp)
Instruction
To start use either ./dev.sh which builds the images locally or ./prod.sh which uses the prebuilt ones from docker hub. Before running this you also need to add the required configuration files (see Configuration).
Configuration
The following configuration files need to be present before starting:
RT_SiteConfig.pm : RTs main configuration file. This needs to be present in the root of the dir. See RT_SiteConfig.pm.example for an example configration and the needed paths and settings for this configuration. For a full config reference have a look at the official documentation.
Caddyfile: The webserver config. See Caddyfile.example for an example and the official Caddy doc for a reference.
./msmtp/msmtp.conf : config for msmtp (outgoing email). See msmtp.conf.example for an example. The ./msmtp folder is also mounted to /msmtp/ in the container so you can load certificates from the config file. MSMTP Configuration Guide
crontab : Crontab file that will be run as the RT user. See contab.example for an example. Crontab output will be sent to the MAILTO address (it uses the msmtp config). You can use crontab guru for help with the format.
./getmail/getmailrc: This file configures your E-Mail fetching. See getmailrc.example for an example. getmail configuration docs are available under https://getmail6.org/configuration.html. The configuration options for rt-mailgate which is used to store the emails in request tracker can be viewed under https://docs.bestpractical.com/rt/latest/rt-mailgate.html.
Additional configs:
./certs/: This folder should contain all optional certificates needed for caddy
./gpg/ : This folder should contain the gpg keyring if used in rt. Be sure to chmod the files to user 1000 with 0600 so RT will not complain. You can also put a dirmngr.conf here to configure dirmngr. For available options see here and here.
./smime/ : This folder should contain the SMIME certificate if configured in RT
./shredder/ : This directory will be used by the shredder functionality https://docs.bestpractical.com/rt/latest/RT/Shredder.html so the backups are stored on the host
For output of your crontabs you can use the /cron directory so the output will be available on the host.
In the default configuration all output from RT, caddy, getmail and msmtp is available via docker logs (or docker compose -f ... logs).
Webserver
The setup uses Caddy as a webserver. You can find an example configuration in Caddyfile.example. Caddy provides features like auto https with lets encrypt and more stuff that makes it easy to set up. You can find the Caddy documentation here https://caddyserver.com/docs/caddyfile.
Feel free to modify the config to your needs like auto https, certificate based authentication, basic authentication and so on. Just be sure the mailgateway host under port :8080 is untouched and the main host contains a block for the unauth API path, otherwise everyone with access to your RT instance can create emails without the need to log in first.
Create Certificate
If you don't want to use the auto https feature (for example in dev) you can provide your own certificates.
Create a self signed certificate:
openssl req -x509 -newkey rsa:4096 -keyout ./certs/priv.pem -out ./certs/pub.pem -days 3650 -nodes
Example Caddy Configurations
Caddy on a domain with lets encrypt certificates
{
admin off
}
# healthchecks
:1337 {
respond "OK" 200
}
# mailgate
:8080 {
log
reverse_proxy rt:9000 {
transport fastcgi
}
}
# request tracker
rt.domain.com:443 {
log
tls user@email.com
# Block access to the unauth mail gateway endpoint
# we have a seperate mailgate server for that
@blocked path /REST/1.0/NoAuth/mail-gateway
respond @blocked "Nope" 403
reverse_proxy rt:9000 {
transport fastcgi
}
}
Caddy behind a reverse proxy server with a self signed certificate
pub.pem and priv.pem need to be inside the ./certs folder and will be mounted automatically.
{
admin off
auto_https off
servers {
trusted_proxies static 10.0.0.0/22
client_ip_headers X-Orig-Addr
trusted_proxies_strict
}
}
# healthchecks
:1337 {
respond "OK" 200
}
# mailgate
:8080 {
log
reverse_proxy rt:9000 {
transport fastcgi
}
}
# request tracker
:443 {
log
tls /certs/pub.pem /certs/priv.pem
# Block access to the unauth mail gateway endpoint
# we have a seperate mailgate server for that
@blocked path /REST/1.0/NoAuth/mail-gateway
respond @blocked "Nope" 403
reverse_proxy rt:9000 {
transport fastcgi {
env SERVER_NAME {http.request.header.X-Orig-HostHeader}
}
}
}
Caddy behind a reverse proxy server with a self signed certificate and client certificate validation
pub.pem, priv.pem and root-ca.pem need to be inside the ./certs folder and will be mounted automatically.
{
admin off
auto_https off
servers {
trusted_proxies static 10.0.0.0/22
client_ip_headers X-Orig-Addr
trusted_proxies_strict
}
}
# healthchecks
:1337 {
respond "OK" 200
}
# mailgate
:8080 {
log
reverse_proxy rt:9000 {
transport fastcgi
}
}
# request tracker
:443 {
log
tls /certs/pub.pem /certs/priv.pem {
protocols tls1.3
client_auth {
mode require_and_verify
trust_pool file /certs/root-ca.pem
}
}
# Block access to the unauth mail gateway endpoint
# we have a seperate mailgate server for that
@blocked path /REST/1.0/NoAuth/mail-gateway
respond @blocked "Nope" 403
reverse_proxy rt:9000 {
transport fastcgi {
env SERVER_NAME {http.request.header.X-Orig-HostHeader}
}
}
}
Caddy behind a reverse proxy server with a self signed certificate and client certificate validation with subject validation
pub.pem, priv.pem and root-ca.pem need to be inside the ./certs folder and will be mounted automatically.
{
admin off
auto_https off
servers {
trusted_proxies static 10.0.0.0/22
client_ip_headers X-Orig-Addr
trusted_proxies_strict
}
}
# healthchecks
:1337 {
respond "OK" 200
}
# mailgate
:8080 {
log
reverse_proxy rt:9000 {
transport fastcgi
}
}
# request tracker
:443 {
@cert-auth {
expression {http.request.tls.client.subject} == "CN=Subject,OU=example,O=com,C=xxx"
}
log
tls /certs/pub.pem /certs/priv.pem {
protocols tls1.3
client_auth {
mode require_and_verify
trust_pool file /certs/root-ca.pem
}
}
# block everything that is not from a trusted ip range
@blocked_trusted not remote_ip 10.0.0.0/22
respond @blocked_trusted "Nope" 403
# Block access to the unauth mail gateway endpoint
# we have a seperate mailgate server for that
@blocked path /REST/1.0/NoAuth/mail-gateway
respond @blocked "Nope" 403
reverse_proxy @cert-auth rt:9000 {
transport fastcgi {
env SERVER_NAME {http.request.header.X-Orig-HostHeader}
}
}
}
Caddy behind a reverse proxy server with a self signed certificate and client certificate validation with subject validation and on a subpath
pub.pem, priv.pem and root-ca.pem need to be inside the ./certs folder and will be mounted automatically. The reverse proxy needs to point to servername/rt otherwise you will end up with wrong paths in the cookies which will lead to file uploads not working correctly.
We will also set the REMOTE_USER to a custom header sent from the upstream proxy.
{
admin off
auto_https off
servers {
trusted_proxies static 10.0.0.0/22
client_ip_headers X-Orig-Addr
trusted_proxies_strict
}
}
# healthchecks
:1337 {
respond "OK" 200
}
# mailgate
:8080 {
log
reverse_proxy rt:9000 {
transport fastcgi
}
}
# request tracker
:443 {
@cert-auth {
expression {http.request.tls.client.subject} == "CN=Subject,OU=example,O=com,C=xxx"
}
log
tls /certs/pub.pem /certs/priv.pem {
protocols tls1.3
client_auth {
mode require_and_verify
trust_pool file /certs/root-ca.pem
}
}
# block everything that is not from a trusted ip range
@blocked_trusted not remote_ip 10.0.0.0/22
respond @blocked_trusted "Nope" 403
handle_path /rt/* {
# Block access to the unauth mail gateway endpoint
# we have a seperate mailgate server for that
@blocked path /REST/1.0/NoAuth/mail-gateway
respond @blocked "Nope" 403
reverse_proxy @cert-auth rt:9000 {
transport fastcgi {
env REMOTE_USER {http.request.header.X-Auth-Username}
env SERVER_NAME {http.request.header.X-Orig-HostHeader}
env REQUEST_URI {uri}
}
}
}
}
Chromium / seccomp
Dashboard emails render their charts with Chromium (WWW::Mechanize::Chrome). Chromium needs user namespaces for its sandbox, which the Docker default seccomp profile blocks without CAP_SYS_ADMIN. The compose file therefore uses seccomp/chrome.json, which is the upstream Docker default profile plus an allow rule for clone, setns and unshare, and raises shm_size to 1GB as Chromium uses /dev/shm heavily.
seccomp/chrome.json is generated by seccomp/generate.sh and kept in sync with upstream by the Update seccomp profile GitHub workflow, which opens a pull request whenever upstream changes.
The host kernel must also allow user namespaces, otherwise Chromium fails with Failed to move to new namespace: ... errno = Operation not permitted. Most current distributions enable them by default, but some older or hardened systems (for example RHEL 7, or hosts hardened with DISA STIG or CIS baselines) set user.max_user_namespaces to 0. Check and enable it on the host:
sysctl user.max_user_namespaces # 0 means disabled
echo 'user.max_user_namespaces = 15000' | sudo tee /etc/sysctl.d/99-userns.conf
sudo sysctl --system
Or with Ansible:
- name: Enable user namespaces for the Chromium sandbox
ansible.posix.sysctl:
name: user.max_user_namespaces
value: "15000"
sysctl_file: /etc/sysctl.d/99-userns.conf
sysctl_set: true
reload: true
become: true
You can verify the setup with docker compose exec rt chromium --headless --dump-dom about:blank.
Init database
This initializes a fresh database. This is needed on the first run.
docker compose run --rm rt bash -c 'cd /opt/rt && perl ./sbin/rt-setup-database --action init'
You need to restart the rt service after this step as it crashes if the database is not initialized.
DEV
Hint: Add --skip-create in dev as the database is created by docker
docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm rt bash -c 'cd /opt/rt && perl ./sbin/rt-setup-database --action init --skip-create'
Upgrade steps
Upgrade Database
docker compose run --rm rt bash -c 'cd /opt/rt && perl ./sbin/rt-setup-database --action upgrade --upgrade-from 4.4.4'
Fix data inconsistencies
Run multiple times with the --resolve switch until no errors occur
docker compose run --rm rt bash -c 'cd /opt/rt && perl ./sbin/rt-validator --check --resolve'
RT-IR
You can simply enable RT-IR in your RT_SiteConfig.pm by including Plugin('RT::IR');. Please refer to the docs for additional install or upgrade steps.
To initialize the database (ONLY ON THE FIRST RUN!!!! and only after rt is fully set up)
docker compose run --rm rt bash -c 'cd /opt/rt && perl ./sbin/rt-setup-database --action insert --skip-create --datafile /opt/rtir/initialdata'