OrbStack 라이선스 만료로 Mac mini Docker 서비스를 GPU 서버로 통합. nginx → Caddy 전환, 12개 서브도메인 자동 HTTPS, fail2ban Caddy JSON 연동. 주요 변경: - home-caddy: Caddy 리버스 프록시 (Let's Encrypt 자동 HTTPS) - home-fail2ban: Caddy JSON 로그 기반 보안 모니터링 - home-ddns: Cloudflare DDNS (API 키 .env 분리) - gpu-hub-api/web: AI 백엔드 라우터 + 웹 UI (gpu-services에서 이전) - AI 런타임(Ollama) 내부망 전용, 외부는 gpu-hub 인증 게이트웨이 경유 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from config import settings
|
|
from middleware.auth import AuthMiddleware
|
|
from routers import auth, chat, embeddings, gpu, health, models
|
|
from services.registry import registry
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await registry.load_backends(settings.backends_config)
|
|
registry.start_health_loop()
|
|
yield
|
|
registry.stop_health_loop()
|
|
|
|
|
|
app = FastAPI(
|
|
title="AI Gateway",
|
|
version="0.1.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins.split(","),
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.add_middleware(AuthMiddleware)
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(chat.router)
|
|
app.include_router(models.router)
|
|
app.include_router(embeddings.router)
|
|
app.include_router(health.router)
|
|
app.include_router(gpu.router)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"service": "AI Gateway", "version": "0.1.0"}
|