How to properly configure Nextcloud mobile synchronization both externally and from the local network?
I’ve installed Nextcloud on a TrueNAS server with a white IP address, forwarded ports, and a domain name. Browser access works correctly from any location, but speeds are significantly higher within the home network.
When setting up automatic synchronization through the Nextcloud mobile app, I encountered an issue: I configured two servers (local and external) on the same user account, but during synchronization, files are being duplicated on the server.
Goal: Automatic data backup when away from home and high-speed synchronization within the network without creating duplicate files.
Questions:
- Could this be related to incorrect Nextcloud configuration?
- How should the system be properly configured to achieve the desired result?
- Is it necessary to configure request redirection from the white IP address within the local network so they don’t route through external servers?
- At what level (in the phone app, in the router, or in Nextcloud settings) should such redirection be configured?
Setting up Nextcloud mobile synchronization to work both from the local network and outside without creating duplicate files requires proper configuration at several levels. The main problem with duplicate files arises because the Nextcloud mobile application doesn’t recognize that two servers (local and external) are actually the same system, and treats them as separate storage.
Table of Contents
- Primary causes of duplicate files
- Proper configuration to prevent duplicates
- Setting up request redirection
- Optimal setup levels
- Additional recommendations
- Step-by-step setup
Primary causes of duplicate files
The problem of duplicate files in your situation is related to the Nextcloud mobile application treating local and remote servers as two different storage systems. This happens for several reasons:
-
Different server addresses: When you use a local IP address for connection within the network and a domain name for external access, the application sees them as different servers.
-
Lack of proper synchronization configuration: As noted in the official discussion, without proper DNS and routing configuration, the application cannot correctly identify the same server.
-
Client version issues: Research shows that in version 4.0.0 of the desktop client, similar problems with creating duplicate folders have been observed.
Proper configuration to prevent duplicates
To achieve your goal - automatic backup when away from home and fast synchronization within the network without duplicates - you need to configure the system as follows:
1. Using a single domain name
Do not configure two separate servers in the Nextcloud application on the same account. Instead:
- Use only one domain name for all connections (e.g.,
drive.example.com) - Configure DNS to resolve this domain name both externally and internally
- Within the network, add an entry to the
hostsfile on your mobile device or configure a local DNS server
2. Router configuration
As experts recommend, to improve performance within the network, you need to:
# Example routing rule for the router
iptables -t nat -A PREROUTING -i eth0 -d YOUR_EXTERNAL_IP -p tcp --dport 443 -j DNAT --to-destination LOCAL_IP:443
This will allow requests from internal devices to route directly to the local server, bypassing external channels.
Setting up request redirection
Answer to question 3: Yes, redirection is required
Yes, you need to configure request redirection from the white IP address within the local network so that they don’t route through external servers. This is critical for performance.
Router-level configuration
- Determine local IP addresses of devices in your network
- Create routing rules for these IP addresses
- Use double NAT or local redirection rules
Example router configuration:
# Internal network: 192.168.1.0/24
# Local server IP: 192.168.1.100
# External server IP: YOUR_WHITE_IP
# Rule for local devices
iptables -t nat -A PREROUTING -s 192.168.1.0/24 -d YOUR_WHITE_IP -j DNAT --to-destination 192.168.1.100
Optimal setup levels
Answer to question 4: Configuration at multiple levels
To achieve optimal performance and avoid duplication, configuration is required at three levels:
1. Router level (primary level)
- Configure routing rules for internal devices
- Enable Smart DNS and local routing functions
- Configure double NAT for proper operation
2. Nextcloud server level
- Configure correct URLs in server settings
- Enable automatic detection of local networks
- Configure external storage for backups
3. Mobile application level
- Use only one connection with the domain name
- Disable manual switching between servers
- Configure Wi-Fi synchronization for automatic network selection
Additional recommendations
Security configuration
As noted in the security guide, for proper operation in a hybrid environment:
Configure Redis for file locking. Since it operates in memory, Redis can handle lock and unlock operations much faster than the database, especially with an active number of users.
Performance optimization
- Enable caching at the application and server levels
- Configure asynchronous processing for preview images
- Optimize network paths for large files
Mobile client configuration
The official documentation recommends:
I use the official mobile and desktop clients and train offline features for travel or dead zones. Device policies regulate PIN/biometrics, device cryptography, and account deletion in case of loss.
Step-by-step setup
Step 1: DNS and router configuration
- Configure a local DNS server to resolve
drive.example.comto the local IP - Create routing rules in the router for internal devices
- Check availability of the domain name from the local network
Step 2: Nextcloud server configuration
- In server settings, specify the correct domain
- Configure external storage for backups
- Enable automatic detection of local networks
Step 3: Mobile application configuration
- Remove all existing connections
- Add only one connection with the domain name
- Configure Wi-Fi synchronization for automatic network selection
Step 4: Testing and verification
- Check synchronization from the local network
- Check synchronization from the external network
- Ensure no duplicates exist on the server
By following these recommendations, you can achieve automatic data backup when away from home and high-speed synchronization within the local network without creating duplicate files.
Sources
- Nextcloud Mobile App DNS Problem - Community Discussion
- Desktop Client Version 4.0.0 Duplicate Folder Issue
- Nextcloud Security Hardening Guide
- Nextcloud Hosting Guide 2025
- How to Fix Slow Nextcloud Performance
- Nextcloud on SynNAS Installation Guide
Conclusion
- The duplicate file problem is related to incorrect routing and DNS configuration, not to errors in Nextcloud itself
- Proper configuration requires coordination at the router, server, and mobile application levels
- Using a single domain name with proper routing is key to solving the problem
- Local optimization through DNS and router configuration will significantly improve performance within the network
- Regular updates of clients and servers will help avoid known version issues
To achieve optimal results, it is recommended to thoroughly test the configuration in a test environment before applying it in a production configuration.