federated share not working: Could not find server

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

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:

Nextcloud version (eg, 29.0.5): 25.0.13
Operating system and version (eg, Ubuntu 29.04): Ubuntu 20.04.6 LTS
Apache or nginx version (eg, Apache 2.4.25): nginx/1.18.0 (Ubuntu)
PHP version (eg, 8.3): 7.4

The issue you are facing:
Similar to this post

I am running two nextcloud instances( nextcloud1 and nextcloud2) on two containers on my server (DATA1 and DATA2).

At first i thought it was something to be solved with an update but it still persists.

Previously i could ping each container from the other but i couldn’t use curl or wget https://nextcloudx.do.ma.in . So in each container i added an ipv6 route to the other website.
Now i can use wget (with --no-check-certificate) and curl just fine.

I also have a mail service set up that is working ( hourly activity report).

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Go to administration settings > Sharing
  2. Trusted servers
  3. paste https://nextcloudx.do.ma.in and click on Add trusted server

The output of your Nextcloud log in Admin > Logging:

[federation] Error: OCP\Http\Client\LocalServerException: Host violates local access rules at <<closure>>

 0. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php line 35
    OC\Http\Client\DnsPinMiddleware->OC\Http\Client\{closure}("*** sensitive parameters replaced ***")
 1. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php line 31
    GuzzleHttp\PrepareBodyMiddleware->__invoke()
 2. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/RedirectMiddleware.php line 71
    GuzzleHttp\Middleware::GuzzleHttp\{closure}("*** sensitive parameters replaced ***")
 3. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php line 63
    GuzzleHttp\RedirectMiddleware->__invoke()
 4. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/HandlerStack.php line 75
    GuzzleHttp\Middleware::GuzzleHttp\{closure}("*** sensitive parameters replaced ***")
 5. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php line 331
    GuzzleHttp\HandlerStack->__invoke()
 6. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php line 168
    GuzzleHttp\Client->transfer()
 7. /usr/share/nginx/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php line 187
    GuzzleHttp\Client->requestAsync("*** sensitive parameters replaced ***")
 8. /usr/share/nginx/nextcloud/lib/private/Http/Client/Client.php line 226
    GuzzleHttp\Client->request()
 9. /usr/share/nginx/nextcloud/apps/federation/lib/TrustedServers.php line 167
    OC\Http\Client\Client->get()
10. /usr/share/nginx/nextcloud/apps/federation/lib/Controller/SettingsController.php line 88
    OCA\Federation\TrustedServers->isNextcloudServer()
11. /usr/share/nginx/nextcloud/apps/federation/lib/Controller/SettingsController.php line 55
    OCA\Federation\Controller\SettingsController->checkServer()
12. /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OCA\Federation\Controller\SettingsController->addServer()
13. /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
14. /usr/share/nginx/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
15. /usr/share/nginx/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
16. /usr/share/nginx/nextcloud/lib/base.php line 1062
    OC\Route\Router->match()
17. /usr/share/nginx/nextcloud/index.php line 38
    OC::handleRequest()

POST /apps/federation/trusted-servers
from my_ipv6_address by root at 2024-06-30T11:58:19+00:00
[federation] Error: OCP\HintException: No server to federate with found at <<closure>>

0. /usr/share/nginx/nextcloud/apps/federation/lib/Controller/SettingsController.php line 55
   OCA\Federation\Controller\SettingsController->checkServer()
1. /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
   OCA\Federation\Controller\SettingsController->addServer()
2. /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
   OC\AppFramework\Http\Dispatcher->executeController()
3. /usr/share/nginx/nextcloud/lib/private/AppFramework/App.php line 183
   OC\AppFramework\Http\Dispatcher->dispatch()
4. /usr/share/nginx/nextcloud/lib/private/Route/Router.php line 315
   OC\AppFramework\App::main()
5. /usr/share/nginx/nextcloud/lib/base.php line 1062
   OC\Route\Router->match()
6. /usr/share/nginx/nextcloud/index.php line 38
   OC::handleRequest()

POST /apps/federation/trusted-servers
from my_ipv6_address by root at 2024-06-30T11:58:19+00:00 

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

root@DATA1:~# cat /usr/share/nginx/nextcloud/config/config.php
<?php
$CONFIG = array (
  'instanceid' => '************',
  'passwordsalt' => '*****************',
  'secret' => '************************************',
  'trusted_domains' => 
  array (
    0 => '[ipv6_address1]', # current instance
    1 => 'nextcloud1.do.ma.in',
  ),
#I tried adding this and then restarting nginx and php but to no avail
  array (
	  0 => '[ipv6_address2]', # instance i want to add as trusted
    1 => 'nextcloud2.do.ma.in',
  ),
  'datadirectory' => '/usr/share/nginx/nextcloud-data',
  'dbtype' => 'mysql',
  'version' => '26.0.13.1',
  'overwrite.cli.url' => 'http://[***********]', #some ipv6 address
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:portnumber*',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '*******',
  'dbpassword' => '*******',
  'installed' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => ****,
  ),
  'mysql.utf8mb4' => false,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'admin',
  'mail_domain' => 'domain_name.com',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.office365.com',
  'mail_smtpport' => '***',
  'mail_smtpname' => 'admin@domain_name.com',
  'mail_smtppassword' => '**********',
);

I also found in federated_cloud_sharing :

Your Apache Web server must have mod_rewrite enabled, and you must have trusted_domains correctly configured in config.php to allow external connections (see Installation wizard). Consider also enabling SSL to encrypt all traffic between your servers .

but it mentions nothing about nginx neitehr here nor in the nginx configuration template in the docs

The output of your Apache/nginx/system log in /var/log/____:
this is all there is of today

root@DATA1:~# cat  /var/log/nginx/nextcloud.error 
2024/06/30 09:46:09 [error] 390#390: *5735 open() "/usr/share/nginx/nextcloud/.well-known/webfinger" failed (2: No such file or directory), client: fd0a:7a43:cee0:0:1106:1:0:2474, server: nextcloud4.qa.mahacapital.admin, request: "GET /.well-known/webfinger HTTP/1.1", host: "nextcloud4.qa.mahacapital.admin"
2024/06/30 09:46:09 [error] 389#389: *5737 open() "/usr/share/nginx/nextcloud/.well-known/nodeinfo" failed (2: No such file or directory), client: fd0a:7a43:cee0:0:1106:1:0:2474, server: nextcloud4.qa.mahacapital.admin, request: "GET /.well-known/nodeinfo HTTP/1.1", host: "nextcloud4.qa.mahacapital.admin"
2024/06/30 09:50:06 [error] 390#390: *5968 open() "/usr/share/nginx/nextcloud/.well-known/webfinger" failed (2: No such file or directory), client: fd0a:7a43:cee0:0:1106:1:0:2474, server: nextcloud4.qa.mahacapital.admin, request: "GET /.well-known/webfinger HTTP/1.1", host: "nextcloud4.qa.mahacapital.admin"
2024/06/30 09:50:06 [error] 390#390: *5959 open() "/usr/share/nginx/nextcloud/.well-known/nodeinfo" failed (2: No such file or directory), client: fd0a:7a43:cee0:0:1106:1:0:2474, server: nextcloud4.qa.mahacapital.admin, request: "GET /.well-known/nodeinfo HTTP/1.1", host: "nextcloud4.qa.mahacapital.admin"
2024/06/30 11:57:44 [error] 26850#26850: *37 open() "/usr/share/nginx/nextcloud/.well-known/webfinger" failed (2: No such file or directory), client: fd0a:7a43:cee0:0:1106:1:0:2474, server: nextcloud4.qa.mahacapital.admin, request: "GET /.well-known/webfinger HTTP/1.1", host: "nextcloud4.qa.mahacapital.admin"
2024/06/30 11:57:44 [error] 26850#26850: *37 open() "/usr/share/nginx/nextcloud/.well-known/nodeinfo" failed (2: No such file or directory), client: fd0a:7a43:cee0:0:1106:1:0:2474, server: nextcloud4.qa.mahacapital.admin, request: "GET /.well-known/nodeinfo HTTP/1.1", host: "nextcloud4.qa.mahacapital.admin"

Note : for the webfinger/nodeinfo error, i thought i had resolved it back in May by commenting the lines in /etc/nginx/conf.d/nextcloud.conf ( found on github)

error_page 403 /core/templates/403.php;

error_page 404 /core/templates/404.php;

The errors from the overview disappeared but now I noticed they’re back.

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

i am not sure i f I have it. this is what i find

root@DATA1:/var/www/html# ll
total 14
drwxr-xr-x 2 root root     4 Apr 15 13:09 ./
drwxr-xr-x 3 root root     3 Oct  9  2020 ../
-rw-r--r-- 1 root root 10918 Apr 15 13:09 index.html
-rw-r--r-- 1 root root   612 Oct  9  2020 index.nginx-debian.html