Built-in Collabora CODE server is not working behind reverse proxy and prefix

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.6.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • opensuse-tumbleweed 20250501
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.62
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • nginx:latest (asdfaasdfasdf, 5 month ago)
  • PHP version (e.g, 8.3):
    • 4.2.27
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • since installation
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • docker pull nextcloud:latest
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

The build-in CODE server is auto-configured and shows “Collabora Online server is reachable.”. When opening an office document, the error “Document loading failed” is shown.
The CODE server works when the document is opened via a the internal server using http and no prefix.

Steps to replicate it (hint: details matter!):

  1. Open the document “Documents/Welcome to Nextcloud Hub.docx”

Log entries

Nextcloud

In the firefox web console, a POST request fails with a 400 error.

https://mydomain/custom_apps/richdocumentscode/proxy.php?req=/browser/636e10a2b1/cool.html?WOPISrc=https://mydomain/prerix/index.php/apps/richdocuments/wopi/files/7_oc4n3n6qtbyt&lang=en&closebutton=1&revisionhistory=1

The prefix is not honored in the request

Web Browser

See above.

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

172.16.0.2 - - [03/Jul/2025:20:35:13 +0000] "GET /nextcloud/custom_apps/richdocumentscode/proxy.php?status HTTP/1.1" 200 15 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0" "-"
172.16.0.2 - - [03/Jul/2025:20:35:13 +0000] "POST /nextcloud/apps/richdocuments/token HTTP/1.1" 200 338 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0" "-"
172.16.0.2 - - [03/Jul/2025:20:35:13 +0000] "PROPFIND /nextcloud/remote.php/dav/files/admin/Documents/Welcome%20to%20Nextcloud%20Hub.docx/ HTTP/1.1" 207 789 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0" "-"
172.16.0.2 - - [03/Jul/2025:20:35:13 +0000] "POST /custom_apps/richdocumentscode/proxy.php?req=/browser/636e10a2b1/cool.html?WOPISrc=https%3A%2F%2Fmydomain%2FyC8u%2Fnxcl%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F7_oc4n3n6qtbyt&lang=en&closebutton=1&revisionhistory=1 HTTP/1.1" 400 154 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0" "-"
172.16.0.2 - - [03/Jul/2025:20:35:14 +0000] "GET /nextcloud/index.php/apps/files/preview-service-worker.js HTTP/1.1" 200 5253 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0" "-"

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "upgrade.disable-web": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "mydomain",
            "localhost",
            "172.16.10.15"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "mydomain",
        "overwriteprotocol": "https",
        "overwrite.cli.url": "https:\/\/mydomain\/nextcloud",
        "overwritewebroot": "\/nextcloud",
        "overwritecondaddr": "^172\\.16\\.0\\.2$",
        "allow_local_remote_servers": true,
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "31.0.6.2",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "loglevel": 2,
        "maintenance": false,
        "app_install_overwrite": []
    }

Apps

The output of occ app:list (if possible).

Enabled:
  - activity: 4.0.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - calendar: 5.3.2
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contacts: 7.1.3
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - mail: 5.1.3
  - notes: 4.12.1
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - oidc: 1.7.2
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - richdocuments: 8.7.1
  - richdocumentscode: 25.4.202
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - spreed: 21.1.0
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - workflowengine: 2.13.0
Disabled:
  - admin_audit: 1.21.0
  - encryption: 2.19.0
  - files_external: 1.23.0
  - nextcloud_announcements: 3.0.0 (installed 3.0.0)
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - twofactor_totp: 13.0.0-dev.0
  - user_ldap: 1.22.0
  - webhook_listeners: 1.2.0 (installed 1.2.0)

The location section of the nginx default.conf

location /nextcloud/ {
    rewrite ^/nextcloud/(.*)$ /$1 break;

    proxy_pass http://172.16.10.15:8086/;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host; # Recommended for Nextcloud behind proxy

    # CalDav and friends
    proxy_buffering off;
    proxy_request_buffering off; # Needed for WebDAV PUT
    proxy_redirect off; # Prevent Nginx from rewriting redirects from Nextcloud
    proxy_http_version 1.1;

    proxy_connect_timeout 600s;
    proxy_read_timeout 720s;
	proxy_send_timeout 720s;
}
1 Like

I don’t recall exactly but there are few things to check

  • richdocuments and built-in CODE don’t take into account Nextcloud OVERWRITE* config settings - they fully rely on reverse proxy headers (x-forwarded..etc)
  • I remember there was an issue with subfolder at all maybe this doesn’t work in general.

we had some related topics here use search :slight_smile:

1 Like

The issue is caused by the CODE server not properly handling the reverse proxy prefix (/nextcloud). The built-in CODE expects to run at the root path, so requests to /nextcloud/custom_apps/... fail with a 400 error because the prefix isn’t respected. To fix this, ensure the overwritewebroot setting is correctly set in config.php (which you have), but also configure the CODE server or reverse proxy to correctly rewrite URLs, or use a dedicated subdomain without a prefix for CODE. The built-in CODE has limited support for reverse proxy prefixes, so separate domain setups are recommended.

2 Likes

:check_mark:

you’re not using the snap, but How to manage Hosts and FQDN for Nextcloud snap may give you some pointers

2 Likes