OnlyOffice Document Server integration demo
- HTML 54.5%
- JavaScript 43.8%
- Dockerfile 1.7%
- Docker Compose setup with OnlyOffice, Node.js app, and nginx proxy - WebSocket support for real-time collaboration - Sample documents (docx, xlsx, pptx) - JWT disabled for demo purposes - Private IP access allowed for Docker networking - nginx reverse proxy with proper WebSocket handling - Comprehensive README with setup instructions |
||
|---|---|---|
| docker/onlyoffice-config | ||
| nginx | ||
| node-app | ||
| .gitignore | ||
| docker-compose.yml | ||
| README.md | ||
OnlyOffice Integration Demo
A demonstration of integrating OnlyOffice Document Server with a Node.js application, proxied through nginx with WebSocket support.
Architecture
Browser → SSH Tunnel → nginx (port 9001) → Node.js App (port 3001)
→ OnlyOffice (port 8080→80)
- nginx: Reverse proxy handling both static files and OnlyOffice with WebSocket support
- Node.js: Serves the demo app UI and document files, handles OnlyOffice callbacks
- OnlyOffice Document Server: Provides the document editing engine
Prerequisites
- Docker & Docker Compose
- SSH access to the host machine (for tunneling)
Quick Start
1. Start the services
cd onlyoffice-integration
docker-compose up -d
2. Create SSH tunnel (from your local machine)
ssh -L 9001:localhost:9001 user@your-server
3. Access the demo
Open your browser: http://localhost:9001/viewer.html?file=sample.docx
Available sample documents:
sample.docx- Word documentsample.xlsx- Excel spreadsheetsample.pptx- PowerPoint presentation
Project Structure
onlyoffice-integration/
├── docker-compose.yml # Docker Compose configuration
├── docker/
│ └── onlyoffice-config/
│ └── local.json # OnlyOffice server configuration
├── node-app/
│ ├── Dockerfile # Node.js app Docker image
│ ├── package.json # Node.js dependencies
│ ├── server.js # Express-like HTTP server
│ ├── index.html # Demo landing page
│ ├── viewer.html # Document viewer/editor page
│ ├── sample.docx # Sample Word document
│ ├── sample.xlsx # Sample Excel spreadsheet
│ └── sample.pptx # Sample PowerPoint
├── nginx/
│ └── onlyoffice-demo.conf # nginx reverse proxy config
└── README.md # This file
Key Configuration
OnlyOffice (docker/onlyoffice-config/local.json)
- JWT tokens disabled - No authentication required for demo
- Private IP access allowed - Enables callbacks from Docker network
- No secrets - Open access for testing
nginx (nginx/onlyoffice-demo.conf)
- Proxies
/to Node.js app - Proxies
/onlyoffice/to OnlyOffice with WebSocket support - Rewrites redirects from
localhostto proper paths - Extended timeouts for long-running document edits
Node.js App (node-app/server.js)
- Serves static HTML files
- Serves sample documents with correct MIME types
- Handles OnlyOffice callback endpoint (
/demo/callback) - Proxies OnlyOffice API requests
Docker Networking
The containers communicate via the onlyoffice-net bridge network:
- Node.js app:
node-app:3001 - OnlyOffice:
onlyoffice:80 - nginx: listens on port 9001
OnlyOffice reaches the Node.js app using the Docker service name node-app, which resolves internally within the Docker network.
Troubleshooting
WebSocket connection failed
- Ensure nginx WebSocket proxy headers are set correctly
- Check that
ds:docserviceis running:docker exec onlyoffice-documentserver supervisorctl status - Verify nginx config:
docker exec onlyoffice-nginx-proxy nginx -t
"Document could not be saved"
- Check OnlyOffice logs:
docker logs onlyoffice-documentserver - Verify callback URL is reachable from OnlyOffice container
- Check Node.js app logs:
docker logs onlyoffice-demo-app
"No rights for action"
JWT tokens might be enabled. Verify local.json has:
"token": {
"enable": {
"browser": false
}
}
OnlyOffice not starting
Wait 30-60 seconds after container start - OnlyOffice takes time to initialize all services.
Development
Rebuild after changes
docker-compose down
docker-compose build --no-cache
docker-compose up -d
View logs
docker-compose logs -f
Access individual containers
docker exec -it onlyoffice-documentserver bash
docker exec -it onlyoffice-demo-app sh
docker exec -it onlyoffice-nginx-proxy sh
Security Notes
⚠️ This is a demo configuration with security disabled:
- JWT authentication is disabled
- No HTTPS/TLS
- Open access to all endpoints
For production use:
- Enable JWT tokens with strong secrets
- Use HTTPS with valid certificates
- Restrict access with authentication
- Set up proper firewall rules
- Enable OnlyOffice rate limiting
License
MIT