Fix external domain access issues when Nextcloud only works locally
Nextcloud External Domain Access Troubleshooting Guide
๐ Problem Description
Nextcloud instance is accessible locally via http://192.168.1.22/index.php/apps/dashboard/ but fails to load when accessing through the external domain https://cloud.adi-protocol.com/index.php/login.
This is a common configuration issue where Nextcloud's trusted domains and URL overwrite settings are not properly configured for external access. The application works perfectly on the local network but becomes inaccessible from outside due to mismatched domain configurations.
๐ฏ Root Cause Analysis
After examining the initial Nextcloud configuration, the issue was identified in the config/config.php file:
'trusted_domains' =>
array (
0 => '192.168.1.22',
1 => 'cloud.adi-protocol.com', // โ
Correctly configured
),
'overwrite.cli.url' => 'http://192.168.1.22', // โ Problem: Local IP only
The trusted_domains was correctly configured, but the overwrite.cli.url setting was pointing to the local IP address with HTTP protocol instead of the external domain with HTTPS.
๐ ๏ธ Solution Implementation
The solution involves updating three critical configuration parameters in Nextcloud's config file.
-
Access the Nextcloud configuration file
Bash
sudo nano /var/www/cloud/config/config.php -
Update the overwrite.cli.url setting
Change from local IP to external domain with HTTPS:
PHP - Before'overwrite.cli.url' => 'http://192.168.1.22',PHP - After'overwrite.cli.url' => 'https://cloud.adi-protocol.com', -
Add missing overwrite parameters
Add these two new configuration lines after the overwrite.cli.url setting:
PHP'overwritehost' => 'cloud.adi-protocol.com', 'overwriteprotocol' => 'https', -
Verify the complete configuration
The final configuration should look like this:
PHP - Final Configuration'ocslxlchipvt', 'passwordsalt' => 'xUAo0F+fCfBuRx3n38TWWwUP6ImRrP', 'secret' => 'IW9UbeK2ybtmC1KB9x5CTql5Ad+ZnpkeAMRcP4V5UDpp+wPJ', 'trusted_domains' => array ( 0 => '192.168.1.22', 1 => 'cloud.adi-protocol.com', ), 'datadirectory' => '/mnt/storage', 'dbtype' => 'mysql', 'version' => '31.0.8.1', 'overwrite.cli.url' => 'https://cloud.adi-protocol.com', 'overwritehost' => 'cloud.adi-protocol.com', 'overwriteprotocol' => 'https', 'dbname' => 'nextcloud_db', 'dbhost' => '192.168.1.60', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextcloud_user', 'dbpassword' => 'DB_EINstein1775_nextcloud_user', 'installed' => true, 'defaultapp' => 'dashboard', ); -
Save and restart the web server
Save the configuration file and restart your web server:
Bash - Apachesudo systemctl restart apache2Bash - Nginxsudo systemctl restart nginx -
Test external access
Navigate to https://cloud.adi-protocol.com/index.php/login to verify the fix.
๐ Configuration Parameters Explained
overwrite.cli.url: Sets the base URL used by Nextcloud for generating links and redirects. This must match your external domain.
overwritehost: Forces Nextcloud to use a specific hostname in generated URLs instead of detecting it from the request headers.
overwriteprotocol: Ensures Nextcloud generates HTTPS URLs even when accessed through proxies or load balancers that might strip SSL.
These settings are crucial when using reverse proxies, load balancers, or accessing Nextcloud through external domains. Without proper configuration, Nextcloud may generate incorrect URLs that point to local addresses instead of external domains.
๐ Prerequisites for External Access
Before implementing this fix, ensure these infrastructure requirements are met:
-
Valid SSL Certificate
Your domain must have a valid SSL certificate configured for HTTPS access. Use Let's Encrypt or a commercial certificate.
-
DNS Configuration
Verify that cloud.adi-protocol.com resolves to your public IP address.
-
Port Forwarding
Configure your router to forward port 443 (HTTPS) to your Nextcloud server at 192.168.1.22.
-
Firewall Configuration
Ensure your server's firewall allows incoming HTTPS connections on port 443.
๐ง Additional Troubleshooting
If the configuration fix doesn't resolve the issue, check these additional factors:
SSL Certificate Problems: Verify your SSL certificate is valid and properly configured for your domain.
Network Connectivity: Test if your domain resolves correctly from external networks.
Web Server Configuration: Check Apache/Nginx virtual host configurations for domain-specific settings.
Cache Issues: Clear browser cache and try accessing from a different browser or incognito mode.
๐ Resolution Results
After implementing the configuration changes and restarting the web server, external access to Nextcloud was successfully restored. Users can now access the instance from anywhere using https://cloud.adi-protocol.com while maintaining local network access via the IP address.
The solution maintains backward compatibility, allowing both local IP access (http://192.168.1.22) and external domain access (https://subdomain.domain.com) to function simultaneously.