I’m running ONLYOFFICE DocumentServer (Docker) using an NGINX reverse proxy integrated with several external Nextcloud servers.
My goal: find a persistent and supported way to:
- Use a fixed, custom JWT secret and header name,
- Keep it across container restarts,
- Ensure compatibility with Nextcloud’s OnlyOffice integration.
Please find the detailled description of my challange:
JWT / Authorization header mismatch:
- ONLYOFFICE automatically generates its own JWT secret when starting.
- When mounting a custom
local.jsonfile or manually editing the secret, the server reverts or rejects the new value. - Result:
403 ForbiddenorInvalid tokenin Nextcloud. - Works only when DocumentServer runs without external JWT configuration or when it can write its own secret.
Configuration persistence & mounting
- Mounting only
/etc/onlyoffice/documentserver/local.jsoncauses file-locking (EBUSY) and overwriting issues. - Mounting the entire directory works better, but still breaks authentication if the secret mismatches.
- The official
JWT_SECRET,JWT_ENABLED, andJWT_HEADERenvironment variables don’t always override existing internal settings.
Time synchronization (timezone drift)
- Container time initially differed by ~2 hours from host (UTC vs CEST).
- Mounting
/etc/localtimeand/etc/timezonefixed that. - NGINX proxy conflicts
- Duplicate
server_namedefinitions and 502/403 errors when misconfigured. - Eventually resolved by cleaning up redundant site configs and ensuring correct upstream to the Docker internal IP.
File permission / user ownership
- Mounted directories (
/srv/onlyoffice,/srv/sftp/onlyoffice) required correct ownership (e.g.,root:rootords:ds) and permissions (755or775). - Behavior difference:
- Everything works perfectly without JWT auth (open access).
- Once JWT is enforced (via secret or header), DocumentServer rejects all connections from Nextcloud with
403.