Acces via VPN with hostname resolving

Nextcloud version (eg, 20.0.5): 20.0.6
Operating system and version (eg, Ubuntu 20.04): Synology DSM 6.2.3
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4
PHP version (eg, 7.4): 7.4

The issue you are facing:
Accessing the Nextcloud hostname via LAN works. As soon as I access my LAN via VPN from outside of the LAN, it seems that the hostname does not get resolved correctly. Opening https:// results in a timeout.

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

Steps to replicate it:

  1. Create a VPN connection with your router, establish the VPN connection.
  2. Open the URL: https:// --> timeout
  3. Open CMD on Windows 10 and execute: nslookup --> the DNS server of the router outside of the LAN tries to resolve instead of the DNS server that was configured for the VPN.
  4. Open CMD on Windows 10 and execute: ipconfig /all -->
    On the running WiFi Adapter:
   Verbindungsspezifisches DNS-Suffix: aircard
   Beschreibung. . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 3165
   Physische Adresse . . . . . . . . : XX-XX-XX-XX-XX-XX
   DHCP aktiviert. . . . . . . . . . : Ja
   Autokonfiguration aktiviert . . . : Ja
   Verbindungslokale IPv6-Adresse  . : XXXX::XXXX:XXXX:XXXX:XXXX%13(Bevorzugt)
   IPv4-Adresse  . . . . . . . . . . : 192.168.2.96(Bevorzugt)
   Subnetzmaske  . . . . . . . . . . : 255.255.255.0
   Lease erhalten. . . . . . . . . . : Freitag, 29. Januar 2021 10:15:23
   Lease läuft ab. . . . . . . . . . : Freitag, 29. Januar 2021 23:31:36
   Standardgateway . . . . . . . . . : 192.168.2.1 <--- Router of the network outside of the LAN
   DHCP-Server . . . . . . . . . . . : 192.168.2.1 
   DHCPv6-IAID . . . . . . . . . . . : XXXXXXXX
   DHCPv6-Client-DUID. . . . . . . . : XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX
   DNS-Server  . . . . . . . . . . . : 192.168.2.1 <--- Router of the network outside of the LAN (NOT the DNS Server of the VPN)
   NetBIOS über TCP/IP . . . . . . . : Aktiviert

On the running VPN-Adapter:

   Verbindungsspezifisches DNS-Suffix: fritz.box
   Beschreibung. . . . . . . . . . . : Shrew Soft Virtual Adapter
   Physische Adresse . . . . . . . . : XX-XX-XX-XX-XX-XX
   DHCP aktiviert. . . . . . . . . . : Nein
   Autokonfiguration aktiviert . . . : Ja
   Verbindungslokale IPv6-Adresse  . : XXXX::XXXX:XXXX:XXXX:XXXX%3(Bevorzugt)
   IPv4-Adresse  . . . . . . . . . . : 192.168.0.201(Bevorzugt)
   Subnetzmaske  . . . . . . . . . . : 255.255.255.0
   Standardgateway . . . . . . . . . : 0.0.0.0
   DHCPv6-IAID . . . . . . . . . . . : XXXXXXXXX
   DHCPv6-Client-DUID. . . . . . . . : XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX-XX
   DNS-Server  . . . . . . . . . . . : 1.1.1.1 <--- public DNS
                                       192.168.1.1 <--- correct DNS Server in order to resolve the nextcloud hostname
   NetBIOS über TCP/IP . . . . . . . : Deaktiviert

NSLOOKUP Results:

Server:  <name of router outside of the LAN>
Address:  192.168.2.1 <--- IP of the router outside of the LAN

*** <hostname nextcloud> wurde von <hostname outside of the LAN> nicht gefunden: Non-existent domain.

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'instanceid' => 'xxxxxxxxxxxx',
  'passwordsalt' => '<passwordsalt>',
  'secret' => '<secret>',
  'trusted_domains' =>
  array (
    0 => '<hostname>',
    1 => '<hostname.dns-suffix>',
    2 => 'IP-Address',
    3 => '<DynDNS-Address>',
    4 => '<hostname.local>',
  ),
  'datadirectory' => '/volume1/nextcloud/data',
  'appstoreenabled' => true,
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/volume1/web/nextcloud/apps',
      'url' => '/apps',
      'writable' => true,
    ),
  ),
  'dbtype' => 'mysql',
  'version' => '20.0.6.1',
  'overwrite.cli.url' => 'https://<DynDNS-Address>',
  'overwriteprotocol' => 'https',
  'dbname' => 'nc',
  'dbhost' => '127.0.0.1:3307',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_user',
  'dbpassword' => '<DB-Password>',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '<name>',
  'mail_domain' => '<domain>',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => '<smtp-server>',

Just remove the public DNS so it is not pushed from your VPN server. Perhaps ask the fritz.box community if you don’t know how.