Django settings overlay
The upstream Django settings are used unmodified. Production tweaks live in a
small overlay shipped alongside them and selected with
DJANGO_SETTINGS_MODULE=ocsinventory_backend.settings_docker:
backend/overlay/ocsinventory_backend/settings_docker.py
It does from .settings import * and then overrides only what a containerized,
reverse-proxied deployment needs. Here is what it changes and why.
Security
DEBUG— parsed robustly from the env (1/true/yes/on); defaults toFalse.- The app refuses to start without a
SECRET_KEYwhenDEBUG=False. ALLOWED_HOSTS,CSRF_TRUSTED_ORIGINS— from env (comma-separated).SECURE_SSL_REDIRECT— off by default (TLS is handled by the nginx edge).
Reverse-proxy / sub-path mounting
FORCE_SCRIPT_NAME— derived fromAPI_BASE_PATH(e.g./api). nginx strips the prefix before proxying; this makes Django regenerate prefixed URLs.USE_X_FORWARDED_HOST = TrueandSECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")— trust the edge's forwarded headers.STATIC_URL/MEDIA_URL— prefixed with the API base (/api/static/,/api/media/).
Static files (WhiteNoise)
- WhiteNoise middleware is inserted right after
SecurityMiddleware. STORAGES["staticfiles"]useswhitenoise.storage.CompressedManifestStaticFilesStorage(hashed, pre-compressed assets).WHITENOISE_STATIC_PREFIX = "/static/"— because nginx strips/api, the app receives/static/...whileSTATIC_URLkeeps the/apiprefix for URL generation. This tells WhiteNoise to match the stripped path it actually receives.
Static files are collected into the image at build time, so every container
has them and ocs-init only handles the database.
Database
- The engine is pinned to
django.db.backends.postgresql(psycopg2 is the only driver installed);DB_ENGINEis not exposed. Connection details come from theDB_*env vars (inherited from the upstream settings).
Logging
LOGGINGis replaced with a single console handler atLOG_LEVEL, so logs go to stdout/stderr and are captured bydocker logs(upstream uses rotating files).
CORS
CORS_ALLOW_ALL_ORIGINSoff by default andCORS_ALLOWED_ORIGINSfrom env — not needed for the single-origin topology, kept for split-origin.
Frontend redirect (SSO)
FRONTEND_REDIRECT— explicit value wins; otherwise derived fromPUBLIC_URL+FRONTEND_BASE_PATH+ocsreports; empty whenPUBLIC_URLis unset (the SSO redirect is then simply disabled). See Admin, auth & agents.