Add base-path deployment support
This commit is contained in:
171
INSTALLATION.md
Normal file
171
INSTALLATION.md
Normal file
@@ -0,0 +1,171 @@
|
||||
# Installation Guide - Ubuntu
|
||||
|
||||
Panduan instalasi `doclink_web` di Ubuntu dengan Apache reverse proxy untuk URL publik seperti:
|
||||
|
||||
```text
|
||||
https://domain.com/docklink-desktop
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Ubuntu Server
|
||||
- Node.js 18+ atau yang kompatibel
|
||||
- Apache2
|
||||
- SSL certificate jika ingin HTTPS
|
||||
|
||||
## 1. Copy Project
|
||||
|
||||
Masuk ke folder project:
|
||||
|
||||
```bash
|
||||
cd /path/to/doclink_web
|
||||
```
|
||||
|
||||
Pastikan file berikut ada:
|
||||
|
||||
- `server.js`
|
||||
- `styles.css`
|
||||
- `logo.png`
|
||||
- `start.sh`
|
||||
- `stop.sh`
|
||||
|
||||
## 2. Jalankan App
|
||||
|
||||
Set base path sesuai URL publik:
|
||||
|
||||
```bash
|
||||
export DOCLINK_BASE_PATH=/docklink-desktop
|
||||
export PORT=5173
|
||||
node server.js
|
||||
```
|
||||
|
||||
Kalau mau jalan di background, pakai script:
|
||||
|
||||
```bash
|
||||
DOCLINK_BASE_PATH=/docklink-desktop PORT=5173 ./start.sh
|
||||
```
|
||||
|
||||
### Catatan
|
||||
|
||||
- `DOCLINK_BASE_PATH` harus sama dengan path publik di browser.
|
||||
- Nama folder project di disk tidak harus sama.
|
||||
- Aplikasi tetap bisa diakses lewat port lokal `5173`, lalu Apache yang meneruskan request ke sana.
|
||||
|
||||
## 3. Install Dependencies Ubuntu
|
||||
|
||||
Update paket dan install Apache:
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y apache2
|
||||
```
|
||||
|
||||
Kalau Node.js belum ada, install sesuai versi yang kamu pakai di server.
|
||||
|
||||
## 4. Aktifkan Module Apache
|
||||
|
||||
Di Ubuntu / Debian:
|
||||
|
||||
```bash
|
||||
sudo a2enmod proxy proxy_http ssl
|
||||
sudo systemctl restart apache2
|
||||
```
|
||||
|
||||
## 5. Buat Virtual Host
|
||||
|
||||
Edit konfigurasi Apache di Ubuntu:
|
||||
|
||||
```bash
|
||||
sudo nano /etc/apache2/sites-available/domain.conf
|
||||
```
|
||||
|
||||
Contoh konfigurasi:
|
||||
|
||||
```apache
|
||||
<VirtualHost *:80>
|
||||
ServerName domain.com
|
||||
Redirect permanent / https://domain.com/
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost *:443>
|
||||
ServerName domain.com
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateFile /path/to/fullchain.pem
|
||||
SSLCertificateKeyFile /path/to/privkey.pem
|
||||
|
||||
ProxyPreserveHost On
|
||||
ProxyRequests Off
|
||||
|
||||
RedirectMatch 301 ^/docklink-desktop$ /docklink-desktop/
|
||||
|
||||
ProxyPass /docklink-desktop/ http://127.0.0.1:5173/
|
||||
ProxyPassReverse /docklink-desktop/ http://127.0.0.1:5173/
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
## 6. Enable Site
|
||||
|
||||
Aktifkan site dan reload Apache:
|
||||
|
||||
```bash
|
||||
sudo a2ensite domain.conf
|
||||
sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
## 7. Test
|
||||
|
||||
Buka URL berikut:
|
||||
|
||||
```text
|
||||
https://domain.com/docklink-desktop/
|
||||
```
|
||||
|
||||
Kalau benar, aplikasi akan tampil tanpa expose port `5173` ke publik.
|
||||
|
||||
## 8. Stop App
|
||||
|
||||
Kalau pakai `start.sh`:
|
||||
|
||||
```bash
|
||||
./stop.sh
|
||||
```
|
||||
|
||||
Kalau mau stop port tertentu:
|
||||
|
||||
```bash
|
||||
./stop.sh 5173
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Halaman tidak muncul
|
||||
|
||||
- Pastikan Node.js app masih jalan di `127.0.0.1:5173`
|
||||
- Pastikan Apache module `proxy` dan `proxy_http` aktif
|
||||
- Pastikan `DOCLINK_BASE_PATH=/docklink-desktop`
|
||||
|
||||
## Ubuntu Notes
|
||||
|
||||
- File konfigurasi Apache biasanya ada di:
|
||||
- `/etc/apache2/sites-available/`
|
||||
- `/etc/apache2/sites-enabled/`
|
||||
- Log Apache biasanya ada di:
|
||||
- `/var/log/apache2/access.log`
|
||||
- `/var/log/apache2/error.log`
|
||||
- Service Apache dikelola dengan:
|
||||
```bash
|
||||
sudo systemctl status apache2
|
||||
sudo systemctl restart apache2
|
||||
sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
### CSS atau logo tidak loading
|
||||
|
||||
- Cek apakah request asset ikut lewat path `/docklink-desktop/...`
|
||||
- Pastikan Apache proxy tidak memotong base path secara salah
|
||||
|
||||
### Redirect balik ke root
|
||||
|
||||
- Pastikan semua request ke app memakai base path yang sama
|
||||
- Gunakan `DOCLINK_BASE_PATH=/docklink-desktop`
|
||||
Reference in New Issue
Block a user