Windows Server Setup
1. Download Required Software
Nginx: http://nginx.org/en/download.html
MongoDB: https://www.mongodb.com/try/download/community
OpenSSL: https://slproweb.com/products/Win32OpenSSL.html
NSSM: https://nssm.cc/download
Python: Microsoft Store or python.org
2. System Setup
mkdir C:\data\db mkdir C:\data\log mkdir C:\nginx
3. Environment Variables
Add to System PATH:
C:\Program Files\MongoDB\Server\6.0\bin C:\nginx
4. MongoDB Configuration
Create file: C:\Program Files\MongoDB\Server\6.0\mongod.cfg
storage: dbPath: C:\data\db security: authorization: enabled systemLog: destination: file path: C:\data\log\mongod.log net: bindIp: 127.0.0.1 port: 27017
5. Install MongoDB Service
mongod --config "C:\Program Files\MongoDB\Server\6.0\mongod.cfg" --install net start MongoDB
6. Nginx Configuration
Create file: C:\nginx\conf\nginx.conf
worker_processes auto; events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65;
}
7. Install Nginx Service
nssm install nginx "C:\nginx\nginx.exe" nssm start nginx
8. SSL Setup
pip install certbot certbot-nginx certbot --nginx -d yourdomain.com -d www.yourdomain.com
9. MongoDB Security
mongosh use admin db.createUser({ user: "adminUser", pwd: "securePassword", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] })
10. Windows Firewall Rules
netsh advfirewall firewall add rule name="HTTP" dir=in action=allow protocol=TCP localport=80 netsh advfirewall firewall add rule name="HTTPS" dir=in action=allow protocol=TCP localport=443 netsh advfirewall firewall add rule name="MongoDB" dir=in action=allow protocol=TCP localport=27017
11. Cloudflare Setup
Create account at cloudflare.com
Add domain
Update nameservers at registrar
Add A record → server IP
Set SSL/TLS to "Full"
12. Service Management Commands
net start MongoDB net stop MongoDB net start nginx net stop nginx nginx -t nginx -s reload
13. Log Locations
Nginx: C:\nginx\logs\access.log, C:\nginx\logs\error.log MongoDB: C:\data\log\mongod.log
14. Monitoring Setup
Open Event Viewer
Create Custom Views for:
MongoDB events
Nginx events
System errors
Security events
15. Backup Configuration
MongoDB Backup: mongodump --out C:\backup\mongodb$(date +%Y%m%d)
Configuration Backup: xcopy C:\nginx\conf C:\backup\nginx\conf /E /I /Y xcopy "C:\Program Files\MongoDB\Server\6.0\mongod.cfg" C:\backup\mongodb\ /Y
16. Security Measures
Windows Updates:
Settings → Update & Security
Enable automatic updates
Windows Defender:
Enable real-time protection
Run weekly full scans
User Access:
Create service accounts
Implement least privilege access
17. Performance Optimization
MongoDB:
Enable WiredTiger cache
Index optimization
Regular maintenance
Nginx:
Worker optimization
Gzip compression
Cache settings
18. Maintenance Schedule
Daily:
Check logs
Verify services
Monitor disk space
Weekly:
Full system backup
Security updates
Log rotation
Monthly:
SSL certificate check
Performance review
Security audit
19. Troubleshooting Guide
Service Issues:
Check service status
Review event logs
Verify configurations
Check port availability
Connection Issues:
Test network connectivity
Verify firewall rules
Check DNS settings
Validate SSL certificates
Performance Issues:
Monitor resource usage
Check log files
Review configurations
Analyze system metrics
20. Emergency Procedures
Service Recovery:
Stop affected service
Check logs
Restore configuration
Start service
Verify functionality
Data Recovery:
Stop services
Restore from backup
Verify data integrity
Start services
Test functionality
Remember to:
Replace placeholder values
Keep secure password copies
Document all custom changes
Maintain backup schedule
Monitor system regularly
Last updated