first commit
This commit is contained in:
103
README.md
Normal file
103
README.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# SPOTA Proxy
|
||||
|
||||
Aplikasi proxy kecil dan terpisah untuk meneruskan request dari project KP ke SPOTA melalui server yang masih bisa mengakses `spota.untan.ac.id`, misalnya `ifserver1`.
|
||||
|
||||
Proxy ini dibuat sebagai produk/deployable terpisah dari `service-portal-kp`. Deploy di `ifserver1`, lalu project KP di `ifserver2` memanggil proxy ini, bukan langsung ke SPOTA.
|
||||
|
||||
## Endpoint
|
||||
|
||||
Default endpoint yang diizinkan:
|
||||
|
||||
- `/login.php`
|
||||
- `/getListTugasAkhir.php`
|
||||
- `/getListMahasiswa.php`
|
||||
- `/getListDosen.php`
|
||||
- `/sendMail.php`
|
||||
- `/healthz`
|
||||
|
||||
Endpoint selain daftar `SPOTA_ALLOWED_ENDPOINTS` akan ditolak dengan `404` supaya service ini tidak menjadi open proxy bebas.
|
||||
|
||||
## Deploy Coolify di ifserver1
|
||||
|
||||
Gunakan resource Docker Compose terpisah.
|
||||
|
||||
Konfigurasi yang disarankan:
|
||||
|
||||
```text
|
||||
Repository: repository spota-proxy ini
|
||||
Branch: main
|
||||
Base directory: spota-proxy
|
||||
Compose file: docker-compose.yml
|
||||
Port aplikasi: 8099
|
||||
```
|
||||
|
||||
Jika repository hanya berisi folder ini, kosongkan `Base directory`.
|
||||
|
||||
Environment minimal:
|
||||
|
||||
```env
|
||||
APP_PORT=8099
|
||||
SPOTA_BASE_URL=https://spota.untan.ac.id/steven/API
|
||||
SPOTA_ALLOWED_ENDPOINTS=login.php,getListTugasAkhir.php,getListMahasiswa.php,getListDosen.php,sendMail.php
|
||||
PROXY_TOKEN=ganti_dengan_token_panjang
|
||||
CONNECT_TIMEOUT=10
|
||||
REQUEST_TIMEOUT=30
|
||||
```
|
||||
|
||||
`PROXY_TOKEN` opsional, tetapi disarankan jika service dapat diakses dari luar network internal.
|
||||
|
||||
## Tes dari ifserver1
|
||||
|
||||
```bash
|
||||
curl -i http://127.0.0.1:8099/healthz
|
||||
```
|
||||
|
||||
Tes akses SPOTA lewat proxy:
|
||||
|
||||
```bash
|
||||
curl -i -X POST "http://127.0.0.1:8099/login.php" \
|
||||
-H "X-Proxy-Token: ganti_dengan_token_panjang" \
|
||||
-d "username=USERNAME_SPOTA" \
|
||||
-d "password=PASSWORD_SPOTA"
|
||||
```
|
||||
|
||||
Jika username/password salah tetapi proxy sehat, respons akan tetap berasal dari SPOTA, misalnya:
|
||||
|
||||
```json
|
||||
{"status":0,"msg":"Username dan password tidak cocok!!!"}
|
||||
```
|
||||
|
||||
## Tes dari ifserver2
|
||||
|
||||
```bash
|
||||
curl -i http://IP_IFSERVER1:8099/healthz
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -i -X POST "http://IP_IFSERVER1:8099/login.php" \
|
||||
-H "X-Proxy-Token: ganti_dengan_token_panjang" \
|
||||
-d "username=USERNAME_SPOTA" \
|
||||
-d "password=PASSWORD_SPOTA"
|
||||
```
|
||||
|
||||
Jika menggunakan domain internal di Coolify, ganti `http://IP_IFSERVER1:8099` dengan URL domain tersebut.
|
||||
|
||||
## Integrasi ke Project KP
|
||||
|
||||
Ubah base URL SPOTA di project KP dari:
|
||||
|
||||
```text
|
||||
https://spota.untan.ac.id/steven/API
|
||||
```
|
||||
|
||||
menjadi URL proxy di `ifserver1`, contoh:
|
||||
|
||||
```text
|
||||
http://IP_IFSERVER1:8099
|
||||
```
|
||||
|
||||
Jika `PROXY_TOKEN` diaktifkan, request dari project KP juga harus mengirim header:
|
||||
|
||||
```text
|
||||
X-Proxy-Token: ganti_dengan_token_panjang
|
||||
```
|
||||
Reference in New Issue
Block a user