Missing public hostname in /hosting/discovery, documents don't load

Problem statement

“Nextcloud Office” with “Collabora Online - Built-in CODE Server” do not work for me: when I open a document, I get a blank page, the document never comes up.

Following the Nextcloud Collabora integration guide, I realized that the public hostname shown in hosting/discovery is wrong: effectively, the domain name is missing:

As you can see in the address bar in the image above, my Nextcloud installation is served under https://nc.bayz.de/nc. Note the directory in addition to the hostname: /nc.
But if you look at the links provided in the wopi-discovery, the hostname is missing in the output! How can I fix this?


When I try to open a document, the browser console reports problems because it tries to open a page without the hostname:

Content Security Policy: The page’s settings blocked the loading of a resource at http://nc/custom_apps/richdocumentscode/proxy.php?status (“connect-src”). core-common.js:2:10473582

(Firefox shown, but Chrome has same troubles).

However, the installation is reported as alright in the admin settings:

Looking at the guide, I tried to set the wopi_url - but I failed. Whatever I input as CODE_URL, the following activate_config always failed:

  • setting CODE_URL to https://nc.bayz.de led to: Client error: GET https://nc.bayz.de/hosting/discovery resulted in a 404 Not Found response
  • setting CODE_URL to https://nc.bayz.de/nc/ led to: Client error: GET https://nc.bayz.de/nc/hosting/discovery resulted in a 404 Not Found response:
  • setting CODE_URL to https://nc.bayz.de/nc/custom_apps/richdocumentscode/proxy.php?req= led to: Client error: GET https://nc.bayz.de/nc/nc/custom_apps/richdocumentscode/proxy.php?req=/hosting/discovery resulted in a 404 Not Found response: ( NOTE: doubled /nc here, where is this coming from ?!)
  • setting CODE_URL to https://nc.bayz.de/custom_apps/richdocumentscode/proxy.php?req= in an attempt to avoide the somehow appearing doubled /nc led to: Client error: GET https://nc.bayz.de/nc/nc/custom_apps/richdocumentscode/proxy.php?req=/hosting/discovery resulted in a 404 Not Found response: - so no success there.

I am not sure where the doubled /nc/nc is coming from in the third step above. Not sure if this has anything to do with all this.

Background information

  • Nextcloud version: 26.0.1, though never worked before in earlier versions
  • Nextcloud installation: official docker image nextcloud:apache
  • Collabora Online - Built-in CODE Server: 22.5.1301
  • Nextcloud Office: 8.0.1
  • Browsers: tested with Firefox 112, Chrome 112
  • nginx reverse proxy: nginx version: nginx/1.20.2 (see below)

The probably most “untypical” part of my setup is the reverse proxy: I use nginx as a reverse proxy, which serves Nextcloud under the location /nc . The proxy configuration is:

location /nc/ {
  add_header Front-End-Https on;
  proxy_buffering off;
  fastcgi_request_buffering off;
  proxy_pass http://nc/;
  client_max_body_size 0;
location = / {
  return 301 https://nc.bayz.de/nc;

For those interested, this is because Nextcloud is launched as part of a mailu installation.

In case it is interesting, the rewrite configuration in config.php is:

# grep -iR overwrite config.php
  'overwrite.cli.url' => 'https://nc.bayz.de/nc',
  'overwritewebroot' => '/nc',
  'overwritehost' => 'nc.bayz.de',
  'overwriteprotocol' => 'https',
  'app_install_overwrite' =>

My question

I assume that the built-in server somehow is not informed about the right public hostname. Thus, links created by it (and sent to the browser) are missing it, are thus wrong, and nothing can work.

Hence I wonder if I can somehow force the public hostname onto the built-in server, to fix this. Is this possible?

1 Like

one big problem is definitely CODE is not aware of the server FQDN showing http://nc/ (which seems to be the internal address used by Nginx to reach the server).

looking through Github issues it looks proxy_set_header Host directive is common. Please give it a try.

 location ^~ / {
     proxy_set_header Host $http_host;

Thank you, this already is a step in a very good direction! I now have at least the right public hostname!

There is still the problem that the path is not right - it is missing the path-prefix/nc.
It needs to be:


instead of


I fixed this mostly by adding a rewrite rule:

location /custom_apps/ {
  return 301 $scheme://nc.bayz.de/nc$request_uri;

However, I still see a white page and the error message in the browser console:

Content Security Policy: The page’s settings blocked the loading of a resource at http://nc.bayz.de/custom_apps/richdocumentscode/proxy.php?req=/browser/6ba7057/cool.html?WOPISrc=https%3A%2F%2Fnc.bayz.de%2Fnc%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F2258237_ocmjl0anm6io&title=testing.odt&lang=en&closebutton=1&revisionhistory=1 (“form-action”).

Brave (Chrome based) shows:

fused to send form data to 'http://nc.bayz.de/custom_apps/richdocumentscode/proxy.php?req=/browser/6ba7057/cool.html?WOPISrc=https%3A%2F%2Fnc.bayz.de%2Fnc%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F2258237_ocmjl0anm6io&title=testing.odt&lang=en&closebutton=1&revisionhistory=1' because it violates the following Content Security Policy directive: "form-action 'self' http://nc".

I am making progress, but I am not there yet. Thanks for the help so far though, that already gave me a lot of good ideas!

yes and there is additional one to the one you spotted already. The scheme is wrong: CODE generated http.//nc… URL but it must do https://nc…

from: Proxy settings — SDK https://sdk.collaboraonline.com/ documentation I see they recommend additional headers like this:

    proxy_set_header           Upgrade $http_upgrade;
    proxy_set_header           Connection "upgrade";

but their config is completely different - my Nginx knowledge is not enough to judge if required - maybe you should check which headers you need to add to properly inform the backend that reverse proxy does TLS termination (likely built-in CODE doesn’t take overwriteprotocol into account). HTTP_X_FORWARDED_PROTO could do the trick

Check Github issues - maybe you find a solution… e.g.

Brave log still expose your internal hostname for some reason (maybe delete cache?):

Update: this post describes in little cumbersome way richdocuments/CODE heavily relyes on proxy headers… definitely try adding headers described above… would be great you post the config once it works