5.0 KiB
5.0 KiB
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 (แนะนำ)
- เข้า Nginx Proxy Manager:
http://your-server:8021 - Login (default: admin@example.com / changeme)
- ไปที่ Proxy Hosts → Add Proxy Host
- กรอกข้อมูล:
- Domain Names:
ai.sriphat.com(หรือ domain ของคุณ) - Scheme:
http - Forward Hostname/IP: ดูจากตารางด้านบน
- Forward Port: ดูจากตารางด้านบน
- Domain Names:
- ไปที่ tab Advanced
- Copy config จากไฟล์ที่เกี่ยวข้อง (เช่น
apiservice.conf) ไปวางใน Custom Nginx Configuration - กด Save
วิธีที่ 2: Import Config Files โดยตรง
⚠️ วิธีนี้ต้องการ access ไปยัง Nginx Proxy Manager data directory
# 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:
server_name ai.sriphat.com; # เปลี่ยนเป็น domain ของคุณ
เปลี่ยน Backend Host/Port
แก้ไข proxy_pass directive:
proxy_pass http://apiservice:8000; # เปลี่ยนตาม service ของคุณ
เพิ่ม SSL/HTTPS
ใช้ Nginx Proxy Manager UI:
- ไปที่ Proxy Host ที่ต้องการ
- ไปที่ tab SSL
- เลือก Request a new SSL Certificate
- เลือก 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_pathdirective - ตรวจสอบ
X-Forwarded-*headers
WebSocket Connection Failed
- ตรวจสอบว่ามี WebSocket headers:
proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
📚 เอกสารเพิ่มเติม
🔐 Security Notes
- ใช้ HTTPS ใน Production - Request SSL certificate ผ่าน Nginx Proxy Manager
- ตั้งค่า Access Lists - จำกัดการเข้าถึงบาง services (เช่น Keycloak Admin)
- Enable Rate Limiting - ป้องกัน DDoS attacks
- Update Regularly - อัพเดท Nginx Proxy Manager เป็นประจำ
📞 Support
หากมีปัญหาหรือข้อสงสัย:
- ตรวจสอบ logs:
docker logs nginx-proxy-manager -f - ดู Nginx Proxy Manager UI → Logs
- ตรวจสอบ backend service logs