Appearance
Zero Sync Server
Overview
Zero Sync server provides real-time data synchronization capabilities for our applications.
Docker Configuration
Container Details
- Image:
rocicorp/zero:latest - Container Name:
oee-zero_cache-1 - Internal Port: 4848
- Host Port: 4848
- Protocol: HTTP/WebSocket
Docker Compose
yaml
services:
zero_cache:
image: rocicorp/zero:latest
container_name: oee-zero_cache-1
ports:
- "4848:4848"
command: /bin/sh -c 'npx zero-cache'
environment:
- NODE_ENV=production
restart: unless-stoppedNginx Configuration
Domain Setup
Domain: zero.hargunrana.com
Location: /etc/nginx/sites-available/zero.hargunrana.com
nginx
server {
server_name zero.hargunrana.com;
location / {
proxy_pass http://localhost:4848;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/zero.hargunrana.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/zero.hargunrana.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = zero.hargunrana.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name zero.hargunrana.com;
return 404;
}Enable the site:
bash
sudo ln -sf /etc/nginx/sites-available/zero.hargunrana.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxAccess Details
Connection URL
https://zero.hargunrana.comWebSocket Connection
javascript
const ws = new WebSocket('wss://zero.hargunrana.com');Firewall Configuration
No additional firewall rules needed - uses standard HTTPS port 443 which is already open.
Monitoring
Check Container Status
bash
docker ps | grep zero
docker logs oee-zero_cache-1Check Service Health
bash
curl https://zero.hargunrana.comMonitor Connections
bash
docker stats oee-zero_cache-1Troubleshooting
Container Issues
bash
# Restart container
docker restart oee-zero_cache-1
# View logs
docker logs -f oee-zero_cache-1
# Check resource usage
docker stats oee-zero_cache-1Connection Issues
bash
# Test local connection
curl http://localhost:4848
# Check nginx proxy
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.logCommon Issues
- WebSocket connection fails: Check nginx upgrade headers
- 502 Bad Gateway: Container may be down, check with
docker ps - SSL errors: Verify certificates are valid and not expired
Integration
Client Configuration
javascript
import { Zero } from '@rocicorp/zero';
const zero = new Zero({
server: 'https://zero.hargunrana.com',
// Additional configuration
});Security Notes
- SSL/TLS enabled by default
- WebSocket connections are encrypted
- Consider adding authentication layer
- Monitor for unusual traffic patterns