Solve "Document loading failed" errors with professional troubleshooting
#Problem Overview
#Solution Reference
This troubleshooting guide is based on the official Collabora Online proxy configuration documentation. For additional technical details and alternative setups, refer to:
This guide solves a complex issue where Nextcloud Office appears to connect to Collabora Online during tests, but fails when users try to open documents. Common in Cloudflare Tunnel + Apache + Docker environments.
- "Document loading failed" - Failed to load Nextcloud Office
- "Could not detect any host" - LocalServerException in logs
- WebSocket connection failures - Socket closed unexpectedly
- 404 errors for browser resources and static assets
#Quick Fix (Most Common Solution)
90% of these issues are caused by Nextcloud's SSRF protection blocking localhost connections. Try this first:
If this doesn't work, continue with the full diagnostic process below.
#Diagnostic Phase
#1.1 Check Nextcloud Logs
First, identify the specific error patterns:
#1.2 Verify Collabora Container
#1.3 Test Built-in Connectivity
- โ Fetched /hosting/discovery endpoint
- โ Valid mimetype response
- โ Valid capabilities entry
- โ Detected WOPI server: Collabora Online
#Fix SSRF Protection
The most common cause is Nextcloud's security feature blocking local server connections:
#Configure Apache Reverse Proxy
For Cloudflare Tunnel environments, use the official SSL termination configuration:
#3.1 Enable Required Apache Modules
#3.2 Update Virtual Host Configuration
- /browser path is essential for CSS, JS, and images
- WebSocket configuration enables collaborative editing
- nocanon flag prevents URL issues
- All internal communication uses HTTP (not HTTPS)
#Configure Collabora for SSL Termination
Since Cloudflare Tunnel handles SSL termination, configure Collabora to expect HTTP internally but know it's behind HTTPS:
#4.1 Update SSL Settings
#4.2 Verify SSL Settings
ssl.enable = false(HTTP internally)ssl.termination = true(Knows it's behind HTTPS)
#Test & Verify Solution
#5.1 Test Collabora Connectivity
#5.2 Check Browser Console
Open Developer Tools (F12) โ Console tab while trying to open a document. Look for:
- No 404 errors for /browser/* resources
- Successful WebSocket connections
- No "Mixed Content" warnings
#5.3 Monitor Real-time Logs
#5.4 Test Document Opening
Try opening different document types:
- .docx files (Word documents)
- .xlsx files (Excel spreadsheets)
- .pptx files (PowerPoint presentations)
#Advanced Troubleshooting
#Missing /browser Path
Symptom: 404 errors for static assets (CSS, JS, images)
Solution: Ensure the /browser proxy configuration is present and properly configured
#WebSocket Failures
Symptom: "Socket connection closed unexpectedly"
Solution: Enable proxy_wstunnel module and verify WebSocket proxy rules
#SSL Configuration Mismatch
Symptom: Mixed content errors, connection refused
Solution: Set Collabora to SSL termination mode (ssl.enable=false, ssl.termination=true)
#Additional Diagnostic Commands
#Success Verification
#You've successfully fixed Nextcloud Office when you see:
- Documents open immediately without loading screens
- No 404 errors in browser console
- WebSocket connections establish successfully
- Real-time collaborative editing works
- No errors in Nextcloud logs during document access
- All document types (.docx, .xlsx, .pptx) open properly
- Cloudflare Tunnel: Use HTTP internally, HTTPS externally
- Direct SSL: Use HTTPS URLs in proxy config
- Docker: Ensure container restart applies config changes
#Prevention & Best Practices
#Best Practices for Prevention
- Document your setup: Keep notes on your specific configuration
- Test after updates: Nextcloud/Collabora updates can break configs
- Monitor logs: Set up log monitoring for early issue detection
- Backup configurations: Save working Apache and Collabora configs
- Use official configs: Stick to Collabora's recommended settings