Configuration Reference
OctoFHIR is configured via a TOML file (default: octofhir.toml). All options can be overridden via environment variables using the OCTOFHIR__ prefix.
Configuration File Location
Section titled “Configuration File Location”# Default location./octofhir.toml
# Custom location via environment variableOCTOFHIR_CONFIG=/path/to/config.toml ./octofhir-serverEnvironment Variable Overrides
Section titled “Environment Variable Overrides”Any configuration option can be overridden via environment variables:
# Pattern: OCTOFHIR__SECTION__SUBSECTION__KEYOCTOFHIR__SERVER__PORT=9000OCTOFHIR__STORAGE__POSTGRES__HOST=db.example.comOCTOFHIR__AUTH__OAUTH__ACCESS_TOKEN_LIFETIME=2hServer Configuration
Section titled “Server Configuration”[server]# Network bindinghost = "0.0.0.0" # Listen addressport = 8888 # Listen port
# Request handlingread_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 deploymentsoutbound_allowlist = [] # with false: private networks/hosts still reachableOutbound requests
Section titled “Outbound requests”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 = falseoutbound_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 Configuration
Section titled “Storage Configuration”PostgreSQL
Section titled “PostgreSQL”[storage.postgres]# Option 1: Connection URL (takes precedence)url = "postgres://user:pass@localhost:5432/octofhir"
# Option 2: Individual settingshost = "localhost"port = 5450user = "postgres"password = "postgres"database = "octofhir"
# Connection poolpool_size = 20 # Max connectionsconnect_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 = 5000FHIR Configuration
Section titled “FHIR Configuration”[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 headerallow_skip_validation = true
[search]default_count = 10 # Default page sizemax_count = 100 # Maximum page sizeFHIR Packages
Section titled “FHIR Packages”[packages]# Base directory for package storagepath = ".fhir"
# Packages to load on startupload = [ "hl7.fhir.r4.core#4.0.1", "hl7.fhir.us.core#6.1.0"]Authentication & Authorization
Section titled “Authentication & Authorization”OAuth 2.0 Settings
Section titled “OAuth 2.0 Settings”[auth]# Issuer URL (should match your public URL)issuer = "http://localhost:8888"
[auth.oauth]# Token lifetimesauthorization_code_lifetime = "10m"access_token_lifetime = "1h"refresh_token_lifetime = "90d"
# Allowed grant typesgrant_types = ["authorization_code", "client_credentials", "refresh_token"]SMART on FHIR
Section titled “SMART on FHIR”[auth.smart]# Launch modeslaunch_ehr_enabled = truelaunch_standalone_enabled = true
# Client typespublic_clients_allowed = trueconfidential_symmetric_allowed = trueconfidential_asymmetric_allowed = true
# Featuresrefresh_tokens_enabled = trueopenid_enabled = truedynamic_registration_enabled = false
# Supported scopessupported_scopes = [ "openid", "fhirUser", "launch", "launch/patient", "offline_access", "patient/*.cruds", "user/*.cruds", "system/*.cruds"]JWT Signing
Section titled “JWT Signing”[auth.signing]# Algorithm: RS256, RS384, or ES384algorithm = "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-----..."""Access Policies
Section titled “Access Policies”[auth.policy]quickjs_enabled = true # Enable JavaScript policy engine
[auth.policy.quickjs]memory_limit_mb = 16max_stack_size_kb = 256timeout_ms = 100Lockout
Section titled “Lockout”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 offduration = "5m"External Identity Providers
Section titled “External Identity Providers”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 pagesauto_provision_users = false # create users the server does not know yetlink_by_email = false # link accounts by verified email; only for providers you controldefault_roles = [] # roles of created usersjwks_cache_ttl = "1h" # when a provider does not say; an unknown kid refetches at onceallow_http = false # providers without TLS, for local testingsaml_certificate = "" # optional: sign SAML requests, with saml_private_keySessions & Cookies
Section titled “Sessions & Cookies”[auth.cookie]enabled = truename = "octofhir_token"secure = false # Set true in production (HTTPS)http_only = truesame_site = "lax"path = "/"
[auth.session]idle_timeout = "30m"absolute_timeout = "8h"cookie_name = "octofhir_sso"cookie_secure = false # Set true in productionCaching
Section titled “Caching”Redis (for horizontal scaling)
Section titled “Redis (for horizontal scaling)”[redis]enabled = false # Enable for multi-instanceurl = "redis://localhost:6380"pool_size = 10timeout_ms = 5000
[cache]terminology_ttl_secs = 3600local_cache_max_entries = 10000Features
Section titled “Features”GraphQL
Section titled “GraphQL”[graphql]enabled = trueintrospection = true # Disable in production for securitymax_depth = 15max_complexity = 500DB Console
Section titled “DB Console”[db_console]enabled = truesql_mode = "admin" # readonly | readwrite | adminlsp_enabled = trueSQL on FHIR
Section titled “SQL on FHIR”[sql_on_fhir]enabled = trueviewdefinition_export = true # ViewDefinition/$export, the export of SQL on FHIR 2.0See SQL on FHIR.
Bulk Data
Section titled “Bulk Data”[bulk_export]spec_version = "stu3" # stu3 | stu4min_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 submitterprovider_client_id = "octofhir-at-a" # optional: this server's client id at the provider, for oauthMetadataUrlprovider_scope = "system/*.read" # scope requested from the provider (this is the default)See Bulk Data for every key.
[mcp]enabled = true # serve POST /mcpallow_writes = false # offer write_resource, recorded as AI assertedSee MCP.
Conformance claims
Section titled “Conformance claims”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.
FHIR Mapping Language
Section titled “FHIR Mapping Language”[fml]enabled = truedebug_role = "admin"timeout_ms = 30000map_folders = [] # maps no package publishes, such as the HL7 cross-version maps[cql]enabled = truemax_retrieve_size = 10000evaluation_timeout_ms = 30000See CQL.
Terminology
Section titled “Terminology”[terminology]server_url = "https://tx.fhir.org/r4"cache_ttl_secs = 3600Audit Trail
Section titled “Audit Trail”[audit]enabled = truelog_fhir_operations = truelog_auth_events = truelog_read_operations = falselog_search_operations = falseexclude_resource_types = ["AuditEvent"]Subscriptions
Section titled “Subscriptions”[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 # defaultsmtp_tls = "starttls" # starttls (default), implicit (port 465) or nonesmtp_username = "fhir"smtp_password = "..."# sendgrid_api_key = "..." # instead of SMTPSee Subscriptions.
Observability
Section titled “Observability”Logging
Section titled “Logging”[logging]# trace | debug | info | warn | error | offlevel = "info"OpenTelemetry
Section titled “OpenTelemetry”[otel]enabled = falseendpoint = "http://localhost:4318"sample_ratio = 0.1 # 10% samplingMetrics and dashboards
Section titled “Metrics and dashboards”/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 APIselector = '{job="octofhir"}' # added to every dashboard queryscrape_interval_secs = 15 # the job's scrape interval: finest step, rate windows ≥ 4×timeout_secs = 10 # per querymax_range_days = 30 # longest range a dashboard may querymax_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, CortexBootstrap
Section titled “Bootstrap”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"Production Example
Section titled “Production Example”[server]host = "0.0.0.0"port = 8888allow_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 = truesame_site = "strict"
[auth.session]cookie_secure = true
[redis]enabled = trueurl = "redis://prod-redis.example.com:6379"
[graphql]introspection = false
[logging]level = "warn"
[otel]enabled = trueendpoint = "https://otel.example.com:4318"sample_ratio = 0.01Local implementation guide packages
Section titled “Local implementation guide packages”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" }]./octofhir-server --config /srv/octofhir/octofhir.tomlThis 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.
Offline package installation
Section titled “Offline package installation”[packages]offline = truepath = "./.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.
Private S3 package objects
Section titled “Private S3 package objects”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 = truepath = "./.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.
Local RustFS verification
Section titled “Local RustFS verification”The repository includes docker-compose.s3.yml with a digest-pinned RustFS 1.0.4
image. Start it with locally chosen credentials:
export RUSTFS_ACCESS_KEY="<local-access-key>"export RUSTFS_SECRET_KEY="<local-secret-key>"docker compose -f docker-compose.s3.yml up -dcurl --fail http://127.0.0.1:9000/healthThe 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:
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-alpineCreate a private bucket and upload the published archive. Explicit environment credentials above keep this example separate from any AWS CLI profile:
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-igsaws --endpoint-url http://127.0.0.1:9000 s3 cp \ "$IG_TGZ" s3://private-igs/igs/ru.core/1/package.tgzGenerate 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:
mkdir -p /tmp/octofhir-s3-examplecat > /tmp/octofhir-s3-example/octofhir.toml <<EOF[fhir]version = "R4B"
[server]host = "127.0.0.1"port = 8080outbound_allowlist = ["127.0.0.1/32"]
[storage.postgres]host = "127.0.0.1"port = 5433database = "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 = falseload = [ { 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-serverThis 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:
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:
docker stop octofhir-s3-example-pgdocker compose -f docker-compose.s3.yml downThe 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:
cargo test -p octofhir-server --test s3_packages -- --nocaptureDocker 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.
DICOMweb connections
Section titled “DICOMweb connections”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.