update configuration docker setup for data platform

This commit is contained in:
jigoong
2026-05-07 17:57:42 +07:00
parent ce949dcc8f
commit 1dba772e62
53 changed files with 6732 additions and 24 deletions

View File

@@ -0,0 +1,149 @@
# Nginx Proxy Manager - Site Configurations
Nginx site configurations สำหรับ handle subpath routing ของทุก service ใน Sriphat Data Platform
## 📋 Services และ Subpaths
| Service | Subpath | Backend | Port |
|---------|---------|---------|------|
| API Service | `/apiservice` | apiservice:8000 | 8040 |
| Supabase Studio | `/supabase` | sdp-studio:3000 | - |
| Supabase Kong API | `/supabase-api` | sdp-kong:8000 | - |
| Keycloak | `/keycloak` | keycloak:8080 | 8085 |
| Superset | `/superset` | superset:8088 | 8088 |
| Airflow | `/airflow` | airflow-webserver:8080 | - |
| DBT Docs | `/dbt` | dbt-docs:8080 | - |
| Dozzle | `/dozzle` | dozzle:8080 | 9999 |
## 🚀 การใช้งาน
### วิธีที่ 1: ใช้ Nginx Proxy Manager UI (แนะนำ)
1. เข้า Nginx Proxy Manager: `http://your-server:8021`
2. Login (default: admin@example.com / changeme)
3. ไปที่ **Proxy Hosts****Add Proxy Host**
4. กรอกข้อมูล:
- **Domain Names**: `ai.sriphat.com` (หรือ domain ของคุณ)
- **Scheme**: `http`
- **Forward Hostname/IP**: ดูจากตารางด้านบน
- **Forward Port**: ดูจากตารางด้านบน
5. ไปที่ tab **Advanced**
6. Copy config จากไฟล์ที่เกี่ยวข้อง (เช่น `apiservice.conf`) ไปวางใน **Custom Nginx Configuration**
7. กด **Save**
### วิธีที่ 2: Import Config Files โดยตรง
**⚠️ วิธีนี้ต้องการ access ไปยัง Nginx Proxy Manager data directory**
```bash
# 1. Copy config files ไปยัง Nginx Proxy Manager
cd /path/to/01-infra
docker cp nginx-configs/. nginx-proxy-manager:/data/nginx/custom/
# 2. Restart Nginx Proxy Manager
docker restart nginx-proxy-manager
# 3. ตรวจสอบ logs
docker logs nginx-proxy-manager -f
```
## 📝 Config Files
### `apiservice.conf`
FastAPI service with Keycloak authentication
- Handles `/apiservice/*` paths
- Preserves session cookies
- WebSocket support
### `supabase-studio.conf`
Supabase Studio UI
- Handles `/supabase/*` paths
- Rewrites paths for Studio
### `supabase-kong.conf`
Supabase REST API (Kong Gateway)
- Handles `/supabase-api/*` paths
- API key authentication
### `keycloak.conf`
Keycloak SSO
- Handles `/keycloak/*` paths
- Preserves authentication headers
### `superset.conf`
Apache Superset BI
- Handles `/superset/*` paths
- Session management
### `airflow.conf`
Apache Airflow (if deployed)
- Handles `/airflow/*` paths
- WebServer UI
### `dbt.conf`
DBT Documentation (if deployed)
- Handles `/dbt/*` paths
- Static documentation
## 🔧 การปรับแต่ง
### เปลี่ยน Domain
แก้ไข `server_name` ในแต่ละ config file:
```nginx
server_name ai.sriphat.com; # เปลี่ยนเป็น domain ของคุณ
```
### เปลี่ยน Backend Host/Port
แก้ไข `proxy_pass` directive:
```nginx
proxy_pass http://apiservice:8000; # เปลี่ยนตาม service ของคุณ
```
### เพิ่ม SSL/HTTPS
ใช้ Nginx Proxy Manager UI:
1. ไปที่ Proxy Host ที่ต้องการ
2. ไปที่ tab **SSL**
3. เลือก **Request a new SSL Certificate**
4. เลือก **Force SSL**
## 🐛 Troubleshooting
### 502 Bad Gateway
- ตรวจสอบว่า backend service ทำงานอยู่: `docker ps`
- ตรวจสอบ network: `docker network inspect shared_data_network`
- ดู logs: `docker logs <service-name>`
### 404 Not Found
- ตรวจสอบ path rewriting ใน config
- ดู nginx logs: `docker logs nginx-proxy-manager`
### Session/Cookie Issues
- ตรวจสอบ `proxy_cookie_path` directive
- ตรวจสอบ `X-Forwarded-*` headers
### WebSocket Connection Failed
- ตรวจสอบว่ามี WebSocket headers:
```nginx
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
```
## 📚 เอกสารเพิ่มเติม
- [Nginx Proxy Manager Documentation](https://nginxproxymanager.com/guide/)
- [Nginx Reverse Proxy Guide](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/)
- [Nginx Subpath Configuration](https://www.nginx.com/blog/creating-nginx-rewrite-rules/)
## 🔐 Security Notes
1. **ใช้ HTTPS ใน Production** - Request SSL certificate ผ่าน Nginx Proxy Manager
2. **ตั้งค่า Access Lists** - จำกัดการเข้าถึงบาง services (เช่น Keycloak Admin)
3. **Enable Rate Limiting** - ป้องกัน DDoS attacks
4. **Update Regularly** - อัพเดท Nginx Proxy Manager เป็นประจำ
## 📞 Support
หากมีปัญหาหรือข้อสงสัย:
1. ตรวจสอบ logs: `docker logs nginx-proxy-manager -f`
2. ดู Nginx Proxy Manager UI → **Logs**
3. ตรวจสอบ backend service logs