GGarudaShield
Dokumentasi

Menjalankan GarudaShield.

Engine edge ditulis dalam Go dengan WAF matcher opsional (Rust, FFI). Panduan ini mencakup instalasi, konfigurasi tiap lapisan pertahanan, admin API, hingga dashboard.

01Build & Jalankan

Engine membutuhkan Go 1.24+. WAF matcher Rust bersifat opsional; jika DLL tidak tersedia, engine otomatis memakai matcher bawaan Go. Dashboard ada di folder dashboard/ (Next.js).

# engine
go build -o bin/gs ./cmd/garudashield        # Windows: -o bin/gs.exe
cp garudashield.example.json garudashield.json
./bin/gs -config garudashield.json           # default :8080

# dashboard (terpisah)
cd dashboard
$env:GS_API_URL="http://localhost:8080"      # URL engine
$env:GS_API_KEY="<admin.secret>"             # sama dgn config
npm install && npm run build && npm start     # http://localhost:3000

# Windows: cukup jalankan run.ps1 (origin + engine + dashboard sekaligus)
./run.ps1

02Struktur Config

Config berbentuk JSON dan kompatibel dengan v2 (config/default.js). Field kosong memakai default aman. Berikut bentuk minimal untuk produksi:

{
  "version": "3.0.0",
  "server":   { "httpPort": 8080, "host": "0.0.0.0", "maxConcurrency": 2048 },
  "upstream": { "host": "127.0.0.1", "port": 9000 },
  "admin":    { "enabled": true, "secret": "GANTI-DENGAN-KEY-KUAT" },
  "proxy":    { "trustProxy": false },
  "defense": {
    "waf":       { "enabled": true, "sqli": true, "xss": true, "commandInjection": true,
                   "pathTraversal": true, "lfi": true, "rfi": true, "shellshock": true, "scanners": true },
    "rateLimit": { "perIPRPS": 50, "perIPBurst": 100, "globalMaxRPS": 50000, "slidingWindowMs": 1000 },
    "layer4":    { "bogonFilter": true }
  },
  "reputation": { "enabled": true, "blockThreshold": 80, "challengeThreshold": 60 },
  "access":     { "enabled": true, "protectAll": false, "hosts": {} },
  "allowedHosts": [],
  "whitelist": ["127.0.0.1", "::1"]
}

03Multi-Site & Proxy

Setiap host dipetakan ke satu site. Engine mengevaluasi keamanan di setiap request (termasuk yang diproxy). Host tak dikenal jatuh ke upstream global.

{
  "sites": {
    "app.example.com":  { "type": "proxy", "upstream": { "host": "10.0.0.5", "port": 8080 } },
    "shop.example.com": { "type": "proxy", "upstream": { "host": "10.0.0.6", "port": 3000 } }
  },
  "upstream": { "host": "127.0.0.1", "port": 9000 }
}

04Trust Proxy (keamanan header)

IP klien hanya diambil dari X-Forwarded-For / X-Real-IP bila koneksi berasal dari proxy terpercaya. Ini mencegah spoofing IP oleh klien langsung.

{
  "proxy": {
    "trustProxy": true,
    "realIpHeader": "X-Forwarded-For",
    "trustedProxies": ["10.0.0.0/24", "192.168.1.10"]
  }
}

05WAF Engine

Modul bawaan: SQLi, XSS, Command Injection, Path Traversal, LFI/RFI, Shellshock, Scanner. Skor tiap aturan diakumulasi; total ≥ 50 memblokir request. Payload ter-encode (single, double, plus) dinormalisasi sebelum dicocokkan, jadi tidak bisa di-bypass dengan encoding.

# toggle modul tanpa restart
POST /api/waf  {"modules": {"sqli": true, "xss": false}}

# tambah custom rule (regex) — skor >= 50 memblokir
POST /api/rules  {"name":"block-bot","pattern":"(?i)evil-agent","score":60}
DELETE /api/rules            # hapus semua custom rule

06Rate Limit

Batas per-IP, per-path, dan global dengan sliding window. RED (Random Early Drop) menurunkan beban sebelum limit keras tercapai. Mode adaptif mengetatkan ambang otomatis saat serangan.

POST /api/ratelimit  {
  "perIPRPS": 50, "perIPBurst": 100,
  "perPathRPS": 200, "globalMaxRPS": 50000,
  "slidingWindowMs": 1000
}

07Verify Browser (Protect)

Interstitial gaya Cloudflare untuk pengunjung pertama. Request tanpa cookie gs_okdijawab challenge ringan; jawaban valid menerbitkan cookie (TTL default 1800 detik). Klien non-browser (curl, skrip) diblokir, bukan di-challenge. Aktifkan per-host dari tab Protect di dashboard, atau nyalakan Protect All untuk seluruh host.

GET  /api/access/hosts                    # daftar host + protectAll
POST /api/access/hosts   {"host":"app.example.com","enabled":true}
POST /api/access/protectall {"enabled":true}

08Cluster Sync

Blokir di satu node langsung disiarkan ke semua node via shared secret (Redis). Full-sync berkala menjaga konsistensi; tombstone mencegah node stale memasukkan kembali IP yang di-unblock.

{
  "cluster": {
    "enabled": true,
    "nodeId": "edge-ny2",
    "redis": { "enabled": true, "address": "127.0.0.1:6379", "keyPrefix": "gs" }
  }
}

09Webhook Alert (Telegram & Discord)

Notifikasi otomatis saat serangan terdeteksi/reda, mode emergency/aggressive/flood berubah, atau ada log kritikal. Filter berdasarkan severity minimum dengan cooldown antar-alert.

{
  "alerts": {
    "enabled": true, "minSeverity": "warning", "cooldownMs": 60000,
    "telegram": { "botToken": "...", "chatId": "..." },
    "discord":  { "webhookUrl": "https://discord.com/api/webhooks/..." }
  }
}
# uji koneksi
POST /api/alerts/test

10Admin API

Semua endpoint butuh x-gs-key (atau Authorization: Bearer), kecuali /api/status yang terbuka. Dashboard menyambung via BFF /api/gs/* yang menyuntikkan key di server.

MethodEndpointFungsi
GET/api/statusHealth & komponen (terbuka)
GET/api/statsStatistik lengkap + volume
GET/api/stats/streamSSE metrik live
GET/api/topTop IP & path
GET/api/logsEvent keamanan terbaru
GET/api/wafKonfigurasi & aturan WAF
POST/api/wafToggle modul WAF
GET/api/ratelimitKonfigurasi & stats rate-limit
GET/api/reputationSkor reputasi per IP
POST/api/blockBlokir IP {ip,reason,duration}
POST/api/unblockCabut blokir {ip}
POST/api/whitelistTambah whitelist {ip}
GET/api/clusterStatus cluster & peer
GET/api/backupEkspor konfigurasi
POST/api/backup/restoreImpor konfigurasi
POST/api/resetReset counter/blocklist/reputasi

11Dashboard & Status

Set GS_API_URL & GS_API_KEY, build, lalu buka /login dan masukkan admin key. Konsol /dash memuat Overview, Traffic, Charts, Geo Map, Top, Logs, Reputation, WAF Rules, Rate Limit, Protect, Cluster, Alerts, dan Settings secara live (polling 1 detik). Halaman status publik terpisah di /status — menampilkan uptime, kesehatan 5 komponen, dan riwayat insiden.

12FAQ

  • Apakah butuh Redis? Tidak wajib. Engine jalan hybrid; Redis opsional untuk shared state antar-instance (cluster).
  • WAF matcher Rust gagal load? Engine otomatis fallback ke matcher Go — tidak fatal, performa tetap baik.
  • Cara mematikan WAF sementara? POST /api/waf {"modules":{"sqli":false,...}} tanpa restart.
  • Volume DDoS diukur bagaimana? Engine menghitung byte on-the-wire tiap request; total dan bagian yang diblokir tampil di Overview/Charts dalam KB/MB/GB/TB.
  • Bisa jalan di belakang Cloudflare/NGINX? Bisa. Aktifkan trustProxy dan daftarkan rentang IP proxy agar IP klien terbaca benar.

Butuh bantuan setup?

Tim teknis membantu konfigurasi dan trial 7 hari.

Konsultasi via WhatsApp