Skip to content

Configuration Reference

OctoFHIR is configured via a TOML file (default: octofhir.toml). All options can be overridden via environment variables using the OCTOFHIR__ prefix.

Terminal window
# Default location
./octofhir.toml
# Custom location via environment variable
OCTOFHIR_CONFIG=/path/to/config.toml ./octofhir-server

Any configuration option can be overridden via environment variables:

Terminal window
# Pattern: OCTOFHIR__SECTION__SUBSECTION__KEY
OCTOFHIR__SERVER__PORT=9000
OCTOFHIR__STORAGE__POSTGRES__HOST=db.example.com
OCTOFHIR__AUTH__OAUTH__ACCESS_TOKEN_LIFETIME=2h

[server]
# Network binding
host = "0.0.0.0" # Listen address
port = 8888 # Listen port
# Request handling
read_timeout_ms = 15000 # Read timeout (15s)
write_timeout_ms = 15000 # Write timeout (15s)
body_limit_bytes = 1048576 # Max request body (1 MiB)
# Outbound requests to client-chosen URLs (subscription rest-hooks, $import sources,
# $bulk-submit file URLs)
allow_private_outbound = true # default; set false on shared or production deployments
outbound_allowlist = [] # with false: private networks/hosts still reachable

API clients choose some of the URLs the server calls: subscription rest-hook endpoints, $import source URLs, and $bulk-submit file URLs with their manifests and OAuth metadata. The Grafana URL of a dashboard export follows the same policy.

Private addresses are allowed by default, so that local setups work. The risk: a client with the right to start such a job can make the server call internal services and the cloud metadata endpoint at 169.254.169.254. Shared or production deployments should set allow_private_outbound = false. The server then only calls public addresses, plus what you list:

[server]
allow_private_outbound = false
outbound_allowlist = [
"172.18.0.0/16", # a Docker network
"10.0.4.17", # a single address
"etl-service", # a host name (it may resolve to any address)
"*.internal.example", # any subdomain
]

Host names are checked when they are resolved, so a name that later points at a private address is refused too; webhooks don’t follow redirects. A subscription whose endpoint is a refused address goes to error with the reason.


[storage.postgres]
# Option 1: Connection URL (takes precedence)
url = "postgres://user:pass@localhost:5432/octofhir"
# Option 2: Individual settings
host = "localhost"
port = 5450
user = "postgres"
password = "postgres"
database = "octofhir"
# Connection pool
pool_size = 20 # Max connections
connect_timeout_ms = 10000 # Connection timeout (10s)
idle_timeout_ms = 60000 # Idle connection timeout (60s)
# Optional: Read replica for scaling reads
# [storage.postgres.read_replica]
# url = "postgres://user:pass@replica:5432/octofhir"
# pool_size = 30 # Defaults to primary pool_size
# connect_timeout_ms = 5000

[fhir]
# Supported versions: R4, R4B, R5, R6 (not published yet, see the FHIR R6 page)
version = "R4"
[validation]
# Allow clients to skip validation via X-Skip-Validation header
allow_skip_validation = true
[search]
default_count = 10 # Default page size
max_count = 100 # Maximum page size

[packages]
# Base directory for package storage
path = ".fhir"
# Packages to load on startup
load = [
"hl7.fhir.r4.core#4.0.1",
"hl7.fhir.us.core#6.1.0"
]

[auth]
# Issuer URL (should match your public URL)
issuer = "http://localhost:8888"
[auth.oauth]
# Token lifetimes
authorization_code_lifetime = "10m"
access_token_lifetime = "1h"
refresh_token_lifetime = "90d"
# Allowed grant types
grant_types = ["authorization_code", "client_credentials", "refresh_token"]
[auth.smart]
# Launch modes
launch_ehr_enabled = true
launch_standalone_enabled = true
# Client types
public_clients_allowed = true
confidential_symmetric_allowed = true
confidential_asymmetric_allowed = true
# Features
refresh_tokens_enabled = true
openid_enabled = true
dynamic_registration_enabled = false
# Supported scopes
supported_scopes = [
"openid",
"fhirUser",
"launch",
"launch/patient",
"offline_access",
"patient/*.cruds",
"user/*.cruds",
"system/*.cruds"
]
[auth.signing]
# Algorithm: RS256, RS384, or ES384
algorithm = "RS384"
# Optional: Fixed keys for token persistence across restarts
# kid = "my-key-id"
# private_key_pem = """-----BEGIN PRIVATE KEY-----..."""
# public_key_pem = """-----BEGIN PUBLIC KEY-----..."""
[auth.policy]
quickjs_enabled = true # Enable JavaScript policy engine
[auth.policy.quickjs]
memory_limit_mb = 16
max_stack_size_kb = 256
timeout_ms = 100

A username or client id that fails to authenticate too often is refused for a while, at the token endpoint and the login form, with 429 and Retry-After. Failures are counted by the name being guessed, so someone who knows a name can lock it out; the lock is short for that reason. Counts live in the memory of the instance.

[auth.lockout]
max_failed_attempts = 5 # 0 turns it off
duration = "5m"

Providers are IdentityProvider resources; these keys say what happens to the people who come through them. See Identity Providers.

[auth.federation]
allow_external_idp = true # offer the active providers on sign-in pages
auto_provision_users = false # create users the server does not know yet
link_by_email = false # link accounts by verified email; only for providers you control
default_roles = [] # roles of created users
jwks_cache_ttl = "1h" # when a provider does not say; an unknown kid refetches at once
allow_http = false # providers without TLS, for local testing
saml_certificate = "" # optional: sign SAML requests, with saml_private_key
[auth.cookie]
enabled = true
name = "octofhir_token"
secure = false # Set true in production (HTTPS)
http_only = true
same_site = "lax"
path = "/"
[auth.session]
idle_timeout = "30m"
absolute_timeout = "8h"
cookie_name = "octofhir_sso"
cookie_secure = false # Set true in production

[redis]
enabled = false # Enable for multi-instance
url = "redis://localhost:6380"
pool_size = 10
timeout_ms = 5000
[cache]
terminology_ttl_secs = 3600
local_cache_max_entries = 10000

[graphql]
enabled = true
introspection = true # Disable in production for security
max_depth = 15
max_complexity = 500
[db_console]
enabled = true
sql_mode = "admin" # readonly | readwrite | admin
lsp_enabled = true
[sql_on_fhir]
enabled = true
viewdefinition_export = true # ViewDefinition/$export, the export of SQL on FHIR 2.0

See SQL on FHIR.

[bulk_export]
spec_version = "stu3" # stu3 | stu4
min_poll_interval_ms = 1000
[bulk_submit]
enabled = true
[[bulk_submit.submitters]]
system = "https://example.org/submitters"
value = "provider-a"
client_id = "provider-a-backend" # optional: only this client may act as the submitter
provider_client_id = "octofhir-at-a" # optional: this server's client id at the provider, for oauthMetadataUrl
provider_scope = "system/*.read" # scope requested from the provider (this is the default)

See Bulk Data for every key.

[mcp]
enabled = true # serve POST /mcp
allow_writes = false # offer write_resource, recorded as AI asserted

See MCP.

Installing a package claims nothing in the CapabilityStatement. Name the IG CapabilityStatements this deployment has been tested against:

[capability]
instantiates = ["http://hl7.org/fhir/us/core/CapabilityStatement/us-core-server"]

Each one goes into CapabilityStatement.instantiates, and its supportedProfile lists join those of the matching resources. The statement has to be in a loaded package; one that is not found is logged and left out.

[fml]
enabled = true
debug_role = "admin"
timeout_ms = 30000
map_folders = [] # maps no package publishes, such as the HL7 cross-version maps

See FHIR Mapping Language.

[cql]
enabled = true
max_retrieve_size = 10000
evaluation_timeout_ms = 30000

See CQL.

[terminology]
server_url = "https://tx.fhir.org/r4"
cache_ttl_secs = 3600
[audit]
enabled = true
log_fhir_operations = true
log_auth_events = true
log_read_operations = false
log_search_operations = false
exclude_resource_types = ["AuditEvent"]
[subscriptions]
enabled = true # activate requested subscriptions and deliver notifications
# Optional: lets `email` channel subscriptions be delivered (otherwise they are put in error)
[subscriptions.email]
from = "fhir@example.org"
smtp_host = "smtp.example.org"
smtp_port = 587 # default
smtp_tls = "starttls" # starttls (default), implicit (port 465) or none
smtp_username = "fhir"
smtp_password = "..."
# sendgrid_api_key = "..." # instead of SMTP

See Subscriptions.


[logging]
# trace | debug | info | warn | error | off
level = "info"
[otel]
enabled = false
endpoint = "http://localhost:4318"
sample_ratio = 0.1 # 10% sampling

/metrics serves Prometheus metrics. The console’s Performance dashboards read them back from Prometheus and appear only when [metrics.prometheus] is set. See Metrics & dashboards.

[metrics]
# Optional: answer /metrics only with `Authorization: Bearer <token>`
# endpoint_token = "…"
[metrics.prometheus]
url = "http://prometheus:9090" # Prometheus-compatible HTTP API
selector = '{job="octofhir"}' # added to every dashboard query
scrape_interval_secs = 15 # the job's scrape interval: finest step, rate windows ≥ 4×
timeout_secs = 10 # per query
max_range_days = 30 # longest range a dashboard may query
max_points = 2000 # per series; longer ranges get a coarser step
# bearer_token = "…" # or basic_username / basic_password
# headers = { "X-Scope-OrgID" = "tenant-1" } # e.g. Mimir, Cortex

Initial setup on first run:

[bootstrap.admin_user]
username = "admin"
password = "admin123" # Change in production!
email = "admin@example.com"
[bootstrap.backend_client]
client_id = "backend"
client_secret = "dev-secret-2024"
scopes = ["system/*.cruds"]
name = "Backend Service"

[server]
host = "0.0.0.0"
port = 8888
allow_private_outbound = false
[storage.postgres]
url = "postgres://user:pass@prod-db.example.com:5432/octofhir?sslmode=require"
pool_size = 50
[fhir]
version = "R4"
[validation]
allow_skip_validation = false
[auth]
issuer = "https://fhir.example.com"
[auth.cookie]
secure = true
same_site = "strict"
[auth.session]
cookie_secure = true
[redis]
enabled = true
url = "redis://prod-redis.example.com:6379"
[graphql]
introspection = false
[logging]
level = "warn"
[otel]
enabled = true
endpoint = "https://otel.example.com:4318"
sample_ratio = 0.01

A packages.load table with path loads a published FHIR package from an unpacked directory, its package/ subdirectory, or a local gzip tar archive such as package.tgz. A plain local path works for a standalone server; a read-only volume mount works in a container. The source is never modified.

Identity is read from package.json; optional id and version must agree with that manifest. Configured local packages must declare the server’s FHIR release. Both fhirVersions and the older published fhir-version-list declaration are accepted, as described in the FHIR package specification. Build FSH source trees before loading them. Use immutable package versions; replacing installed content under the same name and version requires explicit package reinstallation.

[fhir]
version = "R4B"
[packages]
path = "./.fhir"
load = [
"hl7.fhir.r4b.core#4.3.0",
{ path = "./packages/ru-core/package.tgz" },
{ path = "/opt/fhir/private-terminology" }
]

Paths in a TOML configuration, including packages.path, resolve against the configuration file’s directory. Absolute paths remain absolute. When embedding the server and constructing AppConfig directly, relative paths use the process working directory.

Quick start: a local binary or a read-only mount

Section titled “Quick start: a local binary or a read-only mount”

For a standalone server, a normal filesystem path is sufficient. For example, with /srv/octofhir/octofhir.toml use:

[fhir]
version = "R4B"
[packages]
path = "./.fhir"
load = [
"hl7.fhir.r4b.core#4.3.0",
{ path = "./igs/ru.core/package.tgz" }
]
Terminal window
./octofhir-server --config /srv/octofhir/octofhir.toml

This resolves the archive to /srv/octofhir/igs/ru.core/package.tgz. An unpacked package directory works in the same path field. The local IG is loaded from that path; ordinary dependency acquisition remains enabled by default.

For Docker, mount the directory containing the packages read-only, for example ./igs:/opt/igs:ro, then use { path = "/opt/igs/ru.core/package.tgz" } in the mounted server configuration. The operator supplies an existing built package, not an FSH source tree. The cache path remains writable and separate from the read-only source. See the offline section below when registry access must be completely disabled, including transitive dependencies.

Validate resources against an installed custom profile

Section titled “Validate resources against an installed custom profile”

Loading an IG makes its definitions available. A resource declares its applicable profiles through meta.profile; an installed IG does not automatically apply every profile to every resource. Use the canonical URL from the profile’s StructureDefinition, rather than the package name or filesystem path.

This is the same synthetic RuCore Patient shape exercised by the interoperability test. The identifier is a test value:

{
"resourceType": "Patient",
"meta": {
"profile": ["https://fhir.ru/ig/core/StructureDefinition/core-patient"]
},
"identifier": [{
"system": "http://fhir.ru/core/systems/snils",
"value": "123-456-789 00",
"type": {"coding": [{"code": "SB"}]}
}]
}

Send it through the normal POST [fhir-base]/Patient interaction. The loaded profile participates in ordinary write validation; the test verifies that a missing mandatory SNILS slice type is rejected with HTTP 422.

For a validation-only request, call POST [fhir-base]/Patient/$validate with a Parameters resource containing resource (the Patient) and profile.valueUri (the same canonical URL). The result is an OperationOutcome: inspect issue severity for error/fatal, because HTTP 200 alone does not mean the resource passed validation. The RustFS example includes a complete curl request using this profile.

RuCore appears in crates/octofhir-server/tests/ru_core_validation.rs and a pinned test fixture to check real-world interoperability. Runtime package acquisition, profile validation and terminology use the common implementation for any IG.

[packages]
offline = true
path = "./.fhir"
load = [
{ path = "./packages/fhir-core/package.tgz" },
{ path = "./packages/private-ig" },
{ path = "./packages/private-dependency/package.tgz" }
]

Set packages.offline = true to disable package-registry metadata preflight, registry downloads, direct package-URL downloads and runtime registry operations. This setting controls package acquisition; terminology servers and other configured integrations have their own network settings.

Every requested package and its transitive dependencies must already be installed, be supplied by a configured local source, or have an exact-version archive in <packages.path>/cache/<name>-<version>.tgz. Supply the automatically requested HL7 terminology package too (and SQL on FHIR when enabled). Installed packages do not require their original downloaded archives on restart. Explicit local paths must still exist and pass manifest validation on every startup.

For a missing dependency, startup reports its exact name@version and the package that requires it. A private IG is never silently omitted. Archive expansion has compressed/expanded size, per-file size, count and depth limits; escaping paths, links, special files, duplicate entries and invalid index paths are rejected. Configured source installation and schema preparation failures stop startup.

The interoperability suite includes the published ru.core#1 package (FHIR R4B 4.3.0): a read-only directory, a cold offline bootstrap from its unmodified archive and cached dependencies, profile slicing checks and package-local terminology. S3 package acquisition is described below and remains separate from clinical file storage.

S3 sources reference an enabled database-backed StorageProvider. Connection settings and credentials belong to that reusable provider, not to each package. See Storage providers for administrator API/UI, bootstrap, encryption, addressing and examples for AWS S3, R2, Backblaze, Garage and RustFS.

[packages]
offline = true
path = "./.fhir"
load = [
{ path = "./packages/fhir-core/package.tgz" },
{ s3 = { provider = "private-igs", bucket = "private-igs", key = "igs/private.core/1.0.0/package.tgz", sha256 = "<64 hexadecimal digits>" } }
]

Mandatory sha256 pins the compressed object bytes. Optional version_id selects and verifies a specific object version. timeout_ms defaults to 60000 (maximum 300000); max_archive_bytes defaults to 256 MiB (also its maximum). Archives stream into a verified atomic content-addressed cache. Registry-offline mode permits these explicit S3 sources; all transitive dependencies must be supplied or already cached.

The repository includes docker-compose.s3.yml with a digest-pinned RustFS 1.0.4 image. Start it with locally chosen credentials:

Terminal window
export RUSTFS_ACCESS_KEY="<local-access-key>"
export RUSTFS_SECRET_KEY="<local-secret-key>"
docker compose -f docker-compose.s3.yml up -d
curl --fail http://127.0.0.1:9000/health

The S3 API listens on loopback port 9000. Create a bucket and upload package.tgz with an S3 client. Create a StorageProvider with endpoint http://127.0.0.1:9000, set allowHttp = true, reference these credential environment variables, and add 127.0.0.1 to server.outbound_allowlist. Stop the local instance with docker compose -f docker-compose.s3.yml down; its named volume retains test data.

Start OctoFHIR with an IG stored in RustFS

Section titled “Start OctoFHIR with an IG stored in RustFS”

Run the following from the repository root. This local example requires Docker, AWS CLI and the Rust toolchain. It uses the pinned RuCore fixture (FHIR R4B), a local PostgreSQL container and RustFS. Package dependencies are downloaded on first startup; see the offline section above to supply them locally instead.

Start object storage and a separate example database. The password stays in the process environment and is not written into the TOML file:

Terminal window
export RUSTFS_ACCESS_KEY="octofhir-local-ig"
export RUSTFS_SECRET_KEY="$(openssl rand -hex 16)"
export POSTGRES_PASSWORD="$(openssl rand -hex 24)"
export AWS_ACCESS_KEY_ID="$RUSTFS_ACCESS_KEY"
export AWS_SECRET_ACCESS_KEY="$RUSTFS_SECRET_KEY"
export AWS_DEFAULT_REGION="us-east-1"
docker compose -f docker-compose.s3.yml up -d
# Wait for HTTP 200 before uploading the package.
curl --retry 30 --retry-all-errors --retry-delay 1 --fail http://127.0.0.1:9000/health
docker run --detach --rm --name octofhir-s3-example-pg \
--publish 127.0.0.1:5433:5432 \
--env POSTGRES_PASSWORD postgres:18-alpine

Create a private bucket and upload the published archive. Explicit environment credentials above keep this example separate from any AWS CLI profile:

Terminal window
export IG_TGZ="$PWD/crates/octofhir-server/tests/fixtures/ru-core/package.tgz"
export IG_SHA256="$(shasum -a 256 "$IG_TGZ" | awk '{print $1}')"
aws --endpoint-url http://127.0.0.1:9000 s3api create-bucket --bucket private-igs
aws --endpoint-url http://127.0.0.1:9000 s3 cp \
"$IG_TGZ" s3://private-igs/igs/ru.core/1/package.tgz

Generate a complete server configuration. The checksum is substituted into the file; credential fields remain names of environment variables. Its relative cache path is resolved against this configuration file’s directory:

Terminal window
mkdir -p /tmp/octofhir-s3-example
cat > /tmp/octofhir-s3-example/octofhir.toml <<EOF
[fhir]
version = "R4B"
[server]
host = "127.0.0.1"
port = 8080
outbound_allowlist = ["127.0.0.1/32"]
[storage.postgres]
host = "127.0.0.1"
port = 5433
database = "postgres"
username = "postgres"
[auth.policy]
anonymous_access = true
[[storage_providers]]
id = "local-rustfs"
name = "Local IG storage"
type = "s3"
endpoint = "http://127.0.0.1:9000"
region = "us-east-1"
addressingStyle = "path"
allowHttp = true
[storage_providers.credentials]
type = "environment"
accessKeyIdEnv = "RUSTFS_ACCESS_KEY"
secretAccessKeyEnv = "RUSTFS_SECRET_KEY"
[packages]
path = "./.fhir"
offline = false
load = [
{ id = "hl7.fhir.r4b.core", version = "4.3.0", url = "https://hl7.org/fhir/R4B/hl7.fhir.r4b.core.tgz" },
{ s3 = { provider = "local-rustfs", bucket = "private-igs", key = "igs/ru.core/1/package.tgz", sha256 = "$IG_SHA256" } }
]
EOF
export OCTOFHIR__STORAGE__POSTGRES__PASSWORD="$POSTGRES_PASSWORD"
OCTOFHIR_CONFIG=/tmp/octofhir-s3-example/octofhir.toml \
cargo run -p octofhir-server --bin octofhir-server

This example binds the API to loopback and allows anonymous requests for local verification. Use the deployment’s normal authentication policy outside the demo. In another terminal, inspect http://127.0.0.1:8080/fhir/metadata or validate a Patient against the loaded RuCore profile:

Terminal window
curl --fail-with-body http://127.0.0.1:8080/fhir/Patient/\$validate \
--header 'Content-Type: application/fhir+json' \
--data '{"resourceType":"Parameters","parameter":[{"name":"profile","valueUri":"https://fhir.ru/ig/core/StructureDefinition/core-patient"},{"name":"resource","resource":{"resourceType":"Patient","identifier":[{"system":"http://fhir.ru/core/systems/snils","value":"123-456-789 00","type":{"coding":[{"code":"SB"}]}}]}}]}'

The result is an OperationOutcome. Removing identifier.type makes this otherwise base-FHIR-valid example violate the RuCore profile. The fixture tests exercise this positive/negative pair and package-local terminology. The fixture is an interoperability test package, not a claim of national conformance.

To stop these example services:

Terminal window
docker stop octofhir-s3-example-pg
docker compose -f docker-compose.s3.yml down

The database container is ephemeral. The RustFS volume and /tmp/octofhir-s3-example/.fhir cache remain available for the next example run.

The integration test starts its own RustFS and PostgreSQL containers on temporary ports, creates a private bucket, uploads and versions the actual RuCore archive, then boots into an empty database with registry access disabled. It verifies profile and terminology enforcement, rejects invalid signatures/checksums, and restarts from a verified cache without credentials:

Terminal window
cargo test -p octofhir-server --test s3_packages -- --nocapture

Docker is required. The test prepares genuine dependency archives from the package registry first, so its preparation phase needs network access. Package installation in the S3 acceptance phase uses the S3 object and prepared archives only. The pinned image and startup settings follow the RustFS Docker documentation.

See DICOM Integration for named PACS connections and metadata-only Patient/$dicom-import. DICOM objects and pixel data stay in PACS. Optional S3 storage for general Binary/Attachment payloads is a separate planned driver.