1.2 KiB
1.2 KiB
luko-faq-proxy (ifserver2)
Proxy publik untuk bot FAQ Luko. Browser memanggil proxy ini, lalu proxy meneruskan pertanyaan ke endpoint terkunci /faq-api di ifserver1. Endpoint itu hanya menerima IP ifserver2 dan wajib basic auth.
Deploy via Coolify (ifserver2)
- Upload folder ini ke repo Git (GitHub/GitLab), atau ekstrak
luko-faq-proxy.tar.gzlalu push. - Coolify → New Resource → Application → pilih repo tersebut. Build pack: Dockerfile.
- Environment Variables: salin isi
.env.example. - Port:
8080. - Domain: misalnya
https://faq.ifuntanhub.dev. Coolify membuat sertifikat TLS otomatis. - Deploy.
Cek
curl https://faq.ifuntanhub.dev/healthz
curl -X POST https://faq.ifuntanhub.dev/v1/faq -H "Content-Type: application/json" -d '{"query":"siapa kaprodi"}'
Respons: {type: "answer"|"suggest"|"fallback", result, faq_id, score, suggestions: [{id, question}]}.
Frontend
const res = await fetch("https://faq.ifuntanhub.dev/v1/faq", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: pertanyaan }),
});
const data = await res.json();
Origin yang diizinkan diatur di ALLOWED_ORIGINS. Batas request per IP per menit diatur di RATE_MAX.