Skip to main content

Configuration

OpenKSeF can be configured in three ways (in order of priority):

  1. Setup wizard (recommended) -- web wizard at /admin-setup, saves settings in the database (system_config)
  2. .env file -- environment variables next to docker-compose.yml
  3. Default values -- built into docker-compose.yml

Priority: Setup wizard (database) > .env file > default values

For a standard installation, you don't need to create an .env file -- just start the stack and go through the setup wizard. The .env file is useful when you want to change ports, database passwords, or the public URL before the first launch.

Container architecture

All Docker images are published on GitHub Container Registry (ghcr.io/open-ksef/*) and do not require authentication.

ImageDescription
openksef-keycloakKeycloak 26 with built-in OpenKSeF realm (3 OAuth clients: API, mobile, portal-web)
openksef-gatewayNginx with built-in reverse proxy configuration (portal /, API /api/*, Keycloak /auth/*)
openksef-api.NET 8 backend
openksef-worker.NET 8 worker (background invoice synchronization)
openksef-portal-webReact portal (SPA)

Keycloak and gateway have their configuration built into the image -- no need to mount config files or volumes (except the PostgreSQL data volume).

Required variables (API / Worker)

VariableDescriptionDefault
ConnectionStrings__DbPostgreSQL connection stringHost=postgres;Database=openksef;...
Auth__AuthorityKeycloak realm URLhttp://keycloak:8080/auth/realms/openksef
ENCRYPTION_KEYAES-256 key for encrypting KSeF tokens(generated by wizard)
KSeF__BaseUrlKSeF API addresshttps://ksef-test.mf.gov.pl/api

Required variables (Web Portal)

VariableDescriptionDefault
VITE_API_BASE_URLAPI URL for the portal/api
VITE_AUTH_AUTHORITYKeycloak URL for OIDC/auth/realms/openksef
VITE_AUTH_CLIENT_IDClient ID in Keycloakopenksef-portal-web

Infrastructure variables

VariableDescriptionDefault
POSTGRES_USERPostgreSQL useropenksef
POSTGRES_PASSWORDPostgreSQL passwordopenksef_dev_password
KEYCLOAK_ADMINKeycloak admin loginadmin
KEYCLOAK_ADMIN_PASSWORDKeycloak admin passwordadmin
KC_DB_USERNAMEKeycloak database user (if different from Postgres)value of POSTGRES_USER
KC_DB_PASSWORDKeycloak database password (if different from Postgres)value of POSTGRES_PASSWORD
Production

For production deployments, change the default passwords in the .env file. Default values (openksef_dev_password, admin) are intended for development purposes only.

Optional variables

VariableDescription
APP_EXTERNAL_BASE_URLPublic instance URL (e.g. http://192.168.1.50:8080)
GOOGLE_CLIENT_IDGoogle OAuth Client ID (for Google sign-in)
GOOGLE_CLIENT_SECRETGoogle OAuth Client Secret
API_CLIENT_SECRETSecret for openksef-api client in Keycloak (generated by wizard)
FIREBASE_CREDENTIALS_JSONFirebase service account JSON (for direct push)
SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORDMail configuration (email fallback)

KSeF environments

EnvironmentURLUsage
Testhttps://ksef-test.mf.gov.pl/apiDevelopment and testing
Productionhttps://ksef.mf.gov.pl/apiReal invoices
Warning

The production KSeF environment operates on real tax data. Make sure your instance is properly secured before switching to production.

KSeF authentication mode

The KSeF__AuthMode variable supports three modes:

ModeDescription
TokenToken authentication (default)
CertificateCertificate authentication
AutoToken until January 1, 2027, then certificate

Ports

Ports can be customized in .env:

APP_HOST_PORT=8080
API_HOST_PORT=8081
KEYCLOAK_HOST_PORT=8082
PORTAL_WEB_HOST_PORT=8083
POSTGRES_HOST_PORT=5432