Aller au contenu
For the complete DHIS2 documentation index, see llms.txt.

DHIS2 configuration reference (dhis.conf)

This section describes the configuration of the DHIS2 system through the dhis.conf configuration file, followed by the configuration parameters stored in the database (system settings).

The following describes the full set of configuration options for the dhis.conf configuration file. The configuration file should be placed in a directory which is pointed to by a DHIS2_HOME environment variable. On linux systems, if the DHIS2_HOME environment variable is not explicitly set, it defaults to the directory /opt/dhis2/.

Note

You should not attempt to use this configuration file directly, rather use it as a reference for the available configuration options. Many of the properties are optional.

# ----------------------------------------------------------------------
# Database connection for PostgreSQL [Mandatory]
# ----------------------------------------------------------------------

# Hibernate SQL dialect
connection.dialect = org.hibernate.dialect.PostgreSQLDialect

# JDBC driver class
connection.driver_class = org.postgresql.Driver

# Database connection URL
connection.url = jdbc:postgresql:dhis2

# Database username
connection.username = dhis

# Database password (sensitive)
connection.password = xxxx

# ----------------------------------------------------------------------
# Database connection for PostgreSQL [Optional]
# ----------------------------------------------------------------------

# Max size of connection pool (default: 80)
connection.pool.max_size = 80

# Deprecated since v43. Minimum number of connections a pool will maintain at any given time (default: 5).
connection.pool.min_size = 5

# Deprecated since v43. Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize
connection.pool.initial_size = 5

# Deprecated since v43. Determines how many connections at a time will try to acquire when the pool is exhausted.
connection.pool.acquire_incr = 5

#Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire. (default: 7200)
connection.pool.max_idle_time = 7200

# Deprecated since v43. Number of seconds that Connections in excess of minPoolSize should be permitted to remain idle in the pool before being culled (default: 0)
connection.pool.max_idle_time_excess_con = 0

# Deprecated since v43. If this is a number greater than 0, dhis2 will test all idle, pooled but unchecked-out connections, every this number of seconds. (default: 0)
connection.pool.idle.con.test.period = 0

# Deprecated since v43. If on, an operation will be performed at every connection checkout to verify that the connection is valid. (default: false)
connection.pool.test.on.checkout = false

# Deprecated since v43. If on, an operation will be performed asynchronously at every connection checkin to verify that the connection is valid. (default: on)
connection.pool.test.on.checkin = on

# Defines the query that will be executed for all connection tests. Ideally this config is not needed as postgresql driver already provides an efficient test query. The config is exposed simply for evaluation, do not use it unless there is a reason to.
connection.pool.preferred.test.query = select 1

# Deprecated since v43. Configure the number of helper threads used by dhis2 for jdbc operations. (default: 3)
connection.pool.num.helper.threads = 3

# Hikari DB pool feature. Connection pool timeout: Set the maximum number of milliseconds that a client will wait for a connection from the pool. (default: 30ms).
connection.pool.timeout = 30

# Sets the maximum number of milliseconds that the Hikari pool will wait for a connection to be validated as alive. (default: 5ms).
connection.pool.validation_timeout = 5

# Database datasource pool type. Supported pool types are: hikari (default), c3p0 (deprecated), unpooled
db.pool.type = hikari

# ----------------------------------------------------------------------
# Server [Mandatory]
# ----------------------------------------------------------------------

# Base URL to the DHIS2 instance
# The server.base.url setting refers to the externally reachable URL at which the system is accessed by end users over the network.
# Must be an absolute http:// or https:// URL with a valid hostname and no trailing slash.
# Required for password recovery. Also used for OIDC and OAuth2 redirect URLs, notification emails, and interpretation links.
# If missing, invalid, or has a trailing slash, DHIS2 logs a warning at startup. See "Server base URL" below.
server.base.url = https://play.dhis2.org/dev

# Enable secure settings if system is deployed on HTTPS, can be 'off', 'on' (default: 'off')
server.https = off
# It is strongly recommended to enable the `server.https` setting and deploying DHIS 2 with an encrypted HTTPS protocol. This setting will enable e.g. secure cookies. HTTPS deployment is required when this setting is enabled

# ----------------------------------------------------------------------
# System [Optional]
# ----------------------------------------------------------------------

# System mode for database read operations only, can be 'off', 'on'. (default: 'off').
system.read_only_mode = off

# Session timeout in seconds. (default: 3600)
system.session.timeout = 3600

# SQL view protected tables, can be 'on', 'off'. (default: 'on').
system.sql_view_table_protection = on

# SQL view write enabled, can be 'on', 'off'. (default: 'off').
system.sql_view_write_enabled = off

# Remote servers which the server is allowed to call, hostnames should end with '/', default is empty
metadata.sync.remote_servers_allowed = https://server1.org/,https://server2.org/

# Set the maximum size for the cache instance to be built. If set to 0, no caching will take place. Cannot be a negative value. (default: 0.5).
system.cache.max_size.factor = 0.5

# ----------------------------------------------------------------------
# Encryption [Optional]
# ----------------------------------------------------------------------

# Encryption password (sensitive)
encryption.password = xxxx

# ----------------------------------------------------------------------
# File store [Optional]
# ----------------------------------------------------------------------

# File store provider, currently 'filesystem' and 'aws-s3' are supported
filestore.provider = filesystem

# Directory / bucket name, folder below DHIS2_HOME on file system, 'bucket' on AWS S3
filestore.container = files

# URL where the S3 compatible API can be accessed (only for provider 's3')
filestore.endpoint = http://minio:9000 

# Datacenter location (not required)
filestore.location = eu-west-1

# Public identity / username
filestore.identity = dhis2-id

# Secret key / password (sensitive)
filestore.secret = xxxx

# ----------------------------------------------------------------------
# LDAP [Optional]
# ----------------------------------------------------------------------

# LDAP server URL (default: ldaps://0:1)
ldap.url = ldaps://300.20.300.20:636

# LDAP manager user distinguished name
ldap.manager.dn = cn=JohnDoe,ou=Country,ou=Admin,dc=hisp,dc=org

# LDAP manager user password (sensitive)
ldap.manager.password = xxxx

# LDAP entry distinguished name search base
ldap.search.base = dc=hisp,dc=org

# LDAP entry distinguished name filter (default: (cn={0}))
ldap.search.filter = (cn={0})

# ----------------------------------------------------------------------
# Node [Optional]
# ----------------------------------------------------------------------

# Node identifier, optional, useful in clusters
node.id = 'node-1'

# Primary leader. When true, the node will unconditionally set its node ID during leader election causing it to win the election as long as it is alive. Can be true or false (default: false)
node.primary_leader = false

# ----------------------------------------------------------------------
# Monitoring [Optional]
# ----------------------------------------------------------------------

# DHIS2 API monitoring
monitoring.api.enabled = on

# JVM monitoring
monitoring.jvm.enabled = on

# Database connection pool monitoring
monitoring.dbpool.enabled = on

# Hibernate monitoring, do not use in production
monitoring.hibernate.enabled = off

# Uptime monitoring
monitoring.uptime.enabled = on

# CPU monitoring
monitoring.cpu.enabled = on

# Add request context as SQL comments for query attribution. When enabled,
# every SQL statement is prefixed with a comment containing context such as
# the controller and method that triggered the query. Can be 'on', 'off'
# (default: 'off').
monitoring.sql.context = off

# Controls which keys are included in SQL comments. Supported keys:
# controller, method, requestId, sessionId. SQL comments change the query
# text, which can prevent PostgreSQL prepared statement caching. The default
# keys (controller, method) are stable per endpoint, so the same endpoint
# reuses its cached statements. Adding requestId or sessionId produces
# unique SQL text per request or session, which prevents caching entirely
# and can significantly degrade performance. Only enable those for
# debugging. (default: controller,method)
monitoring.sql.context.keys = controller,method

# ----------------------------------------------------------------------
# Redis [Optional]
# ----------------------------------------------------------------------

# Redis enabled
redis.enabled = true

# Redis host name
redis.host = localhost

# Redis port
redis.port = 6379

# Redis password
redis.password = xxxx

# Use SSL for connections to Redis, can be 'on', 'off' (default)
redis.use.ssl = off

# ----------------------------------------------------------------------
# Analytics [Optional]
# ----------------------------------------------------------------------

# Analytics database JDBC driver class
analytics.connection.driver_class = org.postgresql.Driver

# Analytics database connection URL
analytics.connection.url = jdbc:postgresql:analytics

# Analytics database username
analytics.connection.username = analytics

# Analytics database password (sensitive)
analytics.connection.password = xxxx

# Analytics unlogged tables. Can be 'on' (default), 'off'. On will improve analytics geeneration performance at the cost of no replication.
analytics.table.unlogged = on

# Analytics Max size of connection pool (default: 80).
analytics.connection.pool.max_size = 80

# Analytics Minimum number of connections a pool will maintain at any given time (default: 5).
analytics.connection.pool.min_size = 5

# Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. (default: 5).
analytics.connection.pool.initial_size = 5

# If present, overrides the analytics.connection.url value - useful when running Apache Doris in a container (so it is not able to access Postgres via `localhost`).
doris.catalog.connection.url =  https://doris.example.org


# ----------------------------------------------------------------------
# System telemetry [Optional]
# ----------------------------------------------------------------------

# System monitoring URL
system.monitoring.url = 

# System monitoring username
system.monitoring.username = 

# System monitoring password (sensitive)
system.monitoring.password = xxxx

# ----------------------------------------------------------------------
# System update notifications [Optional]
# ----------------------------------------------------------------------

# System update notifications, such as new DHIS 2 releases becoming available. The system will default send a notification in the mail inbox under the "system" category when there is a new DHIS2 patch version available for download.
# This notification will be sent to the users who have the "ALL" authority, unless the "System update notification recipients" user group is defined, under the "General settings". It can be 'off', 'on' (default: 'on')
system.update_notifications_enabled = on

# ----------------------------------------------------------------------
# Logging [Optional]
# ----------------------------------------------------------------------

# Max size for log files, default is 100MB
logging.file.max_size = 200MB

# Max number of rolling log archive files, default is 0
logging.file.max_archives = 1

# Enable query logging. Can be 'on', 'off' (default: 'off').
logging.query = off

# Log queries slower than this threshold in milliseconds at WARN level
# (default: 1000).
logging.query.slow_threshold = 1000

# Add a hashed session ID to the logging context (MDC). Include it in log
# output via %X{sessionId} in the log4j2 pattern layout. Can be 'on', 'off'
# (default: 'on').
logging.session_id = on

# ----------------------------------------------------------------------
# Log levels [Optional]
# ----------------------------------------------------------------------

# DHIS 2 log level (level can be TRACE, DEBUG, INFO, WARN, ERROR)
logging.level.org.hisp.dhis = INFO

# Spring log level (refers to Java class package names)
logging.level.org.springframework = INFO

# ----------------------------------------------------------------------
# App Hub [Optional]
# ----------------------------------------------------------------------

# Base URL to the DHIS2 App Hub service (default: https://apps.dhis2.org)
apphub.base.url = https://apps.dhis2.org

# Base API URL to the DHIS2 App Hub service, used for app updates (default: https://apps.dhis2.org/api)
apphub.api.url = https://apps.dhis2.org/api

# ----------------------------------------------------------------------
# Sessions [Optional]
# ----------------------------------------------------------------------

# Number of possible concurrent sessions across different clients per user
max.sessions.per_user = 10

# ----------------------------------------------------------------------
# Route API [Optional]
# ----------------------------------------------------------------------

# Remote servers allowed to call from the route endpoint. Default is any HTTPS URL. Wildcards are allowed. 
# e.g. route.remote_servers_allowed = https://server1.com/,https://server2.com/,https://192.168.*.*
route.remote_servers_allowed = https://*

Notez que le fichier de configuration prend en charge les variables d'environnement. Cela signifie que vous pouvez définir certaines propriétés comme variables d'environnement et les résoudre. C'est le cas de l'exemple suivant où DB_PASSWD est le nom de la variable d'environnement :

connection.password = ${DB_PASSWD}

Notez que ce fichier contient le mot de passe de votre base de données DHIS2 en texte clair et qu'il doit donc être protégé contre tout accès non autorisé. Pour ce faire, appelez la commande suivante qui garantit que seul l'utilisateur dhis est autorisé à le lire :

chmod 600 dhis.conf

Server base URL

The server.base.url property in dhis.conf defines the externally reachable base URL of the DHIS2 instance — the URL users type into their browser to access the system. Setting this value correctly is important: several DHIS2 features generate links from it, and a missing or malformed value breaks them.

server.base.url = https://dhis2.example.org/dhis

Why it matters

DHIS2 uses server.base.url to build absolute URLs in backend-generated content. Features that depend on it include:

  • Password recovery — the account recovery email contains a reset link built from server.base.url. If the property is missing or invalid, password recovery is unavailable.
  • OIDC and OAuth2 — redirect URIs and client registration URLs are derived from this value.
  • Notification emails — links in interpretation, message, and subscription emails point to this base.
  • Interpretation sharing — shared links to dashboards, visualizations, and maps.
  • API metadata URLs — some system info and metadata endpoints emit absolute URLs based on this value.

Valid values

The value must be an absolute URL that is reachable by your end users:

  • Scheme: https:// (strongly recommended) or http:// for non-TLS environments.
  • Hostname: a valid hostname or IP reachable from users' browsers — not localhost in a production deployment.
  • No trailing slash.
  • Include the context path (e.g., /dhis) if DHIS2 is not deployed at the server root.

Exemples :

# Good
server.base.url = https://dhis2.example.org
server.base.url = https://dhis2.example.org/dhis

# Bad — trailing slash
server.base.url = https://dhis2.example.org/

# Bad — no scheme
server.base.url = dhis2.example.org

# Bad — not reachable by end users
server.base.url = http://localhost:8080

Startup validation

At startup, DHIS2 validates server.base.url and logs a WARN message if the value is missing, empty, not a valid absolute URL, or has a trailing slash. DHIS2 will continue to start in this state (in degraded mode for the features listed above), but administrators should treat the warning as something to fix.

Configuration du cryptage{ #install_encryption_configuration }

DHIS2 permet de crypter les données. L'activation du cryptage nécessite une configuration supplémentaire. Pour assurer la sécurité de l'algorithme de cryptage, vous devrez définir un mot de passe (clé) dans le fichier de configuration dhis.conf via la propriété encryption.password :

encryption.password = xxxx

La propriété encryption.password est le mot de passe (clé) utilisé lors du cryptage et du décryptage des données dans la base de données.

Si un mot de passe de cryptage n'est pas défini dans dhis.conf, un mot de passe par défaut sera utilisé. Notez que l'utilisation du mot de passe par défaut n'augmente pas la sécurité en raison de la nature open source de DHIS 2.

Le mot de passe ne doit pas être modifié une fois défini et les données cryptées. Autrement, ces données ne pourront plus être décryptées par l'application.

Le mot de passe doit comporter au moins 24 caractères. Une combinaison de chiffres et de lettres minuscules et majuscules est recommandé. Le mot de passe de cryptage doit être gardé secret.

Important

La récupération de données de données cryptées n'est pas possible si le mot de passe de cryptage est perdu ou modifié. Si le mot de passe est perdu, les données cryptées le seront également. A l’inverse, le cryptage n’offre aucune sécurité si le mot de passe est compromis. Il est donc très important de garder le mot de passe dans un endroit sûr.

Etant donné que la clé de cryptage est stockée dans le fichier de configuration dhis.conf et non dans la base de données, lors du déplacement d'une base de données entre différents environnements de serveur par le biais d'un vidage et d'une restauration (dump and restore), la clé de cryptage doit être la même dans tous ces environnements pour permettre à DHIS 2 de décrypter le contenu de la base de données.

La prise en charge du cryptage dépend de la disponibilité des fichiers de stratégie Java Cryptography Extension (JCE). Ces fichiers sont inclus dans toutes les versions d'OpenJDK et d'Oracle JDK 8 Update 144 et les versions ultérieures.

Configuration du système

Cette section aborde diverses propriétés de configuration du système.

system.read_only_mode = on | désactivé

Définit le système sur le mode lecture seule. Ceci est utile lorsque vous exécutez DHIS 2 sur une base de données réplica en lecture seule, afin d'éviter que DHIS 2 n'effectue des opérations d'écriture sur la base de données. Peut être activé ou désactivé. La valeur par défaut est désactivé.

system.session.timeout = (seconds)

Définit le délai d'expiration de la session utilisateur en secondes. La valeur par défaut est 3.600 secondes (1 heure).

system.sql_view_table_protection = on | off

Active ou désactive la protection des tableaux de base de données sensibles pour les vues SQL. Grâce à cette protection, les tableaux de base de données contenant des données sensibles ne pourront pas être interrogées par le biais des vues SQL. La désactivation n'est pas recommandée. Peut être activé ou désactivé. La valeur par défaut est on.

system.system.sql_view_write_enabled = on | off

Active ou désactive les autorisations d'écriture pour les vues SQL. Cela empêchera la vue SQL d'effectuer des écritures sous-jacentes (la requête peut être une sélection qui nécessite une autorisation d'écriture). L'activation n'est pas recommandée. La désactivation n'est pas recommandée ; peut être activé ou désactivé. La valeur par défaut est on.

Enable TOTP (OTP-based) 2FA:

TOTP (Time-Based One-Time Password) uses apps like Google Authenticator or Authy to generate a time-sensitive one-time password. To enable TOTP 2FA, set the following:

login.security.totp_2fa.enabled = on

Enable Email-Based 2FA:

Email-based 2FA sends a verification code to the user's email address during login. The user must enter this code to complete the login process. To enable email-based 2FA, set the following:

login.security.email_2fa.enabled = on