Setup server infrastructure yang reliable adalah fondasi dari sistem production yang stabil. Dalam artikel ini, kita membahas langkah-langkah essential untuk menyiapkan server Linux yang siap production — dari konfigurasi awal hingga monitoring.
🖥️ Memilih Server
Pertimbangkan faktor berikut dalam memilih server:
- Cloud vs On-premise — Cloud (AWS, GCP, DigitalOcean) untuk fleksibilitas, on-premise untuk compliance tertentu
- Spesifikasi — CPU, RAM, dan storage sesuai kebutuhan workload
- Lokasi — Pilih region terdekat dengan target user untuk latency rendah
- OS — Ubuntu Server 22.04 LTS atau Debian 12 untuk stabilitas jangka panjang
🔒 Security Hardening
1. SSH Configuration
# Disable root login
PermitRootLogin no
# Disable password authentication
PasswordAuthentication no
# Use key-based authentication only
PubkeyAuthentication yes
2. Firewall Setup
# UFW basic configuration
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
3. Automatic Security Updates
sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
🌐 Web Server Setup (Nginx)
Nginx adalah reverse proxy yang ringan dan performant:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
🔐 SSL/TLS dengan Let's Encrypt
HTTPS adalah mandatory untuk production:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
Certbot akan otomatis mengkonfigurasi Nginx dan menjadwalkan renewal.
📊 Process Management (PM2)
Gunakan PM2 untuk menjalankan Node.js apps di production:
pm2 start app.js --name "myapp" -i max
pm2 save
pm2 startup
PM2 menyediakan automatic restart, load balancing, dan log management.
🔍 Monitoring & Logging
- htop / glances — Real-time system monitoring
- Netdata — Dashboard monitoring gratis
- Logrotate — Manage log file rotation
- Uptime monitoring — UptimeRobot atau Pingdom untuk external checks
Server yang tidak dimonitor adalah bom waktu. Setup alerting untuk CPU, memory, disk, dan response time.

