Caddy Server REST API kullanarak proxy yönlendirmeleri, SSL sertifikaları, API kullanıcıları ve Dashboard kullanıcı yönetimini içeren kapsamlı bir web yönetim panelidir.
- Proxy Yönetimi: Caddy Server üzerinden proxy konfigürasyonları oluşturma, düzenleme ve silme
- SSL Sertifika Yönetimi: ACME sertifika durumları, geçerlilik tarihleri ve otomatik yenileme
- API Token Yönetimi: Güvenli API anahtarları oluşturma ve yönetimi
- Kullanıcı Yönetimi: Dashboard kullanıcıları için authentication ve authorization
- HOST-based Routing: Environment değişkeni ile dinamik hostname routing
- Modern UI: Next.js + TypeScript + Tailwind ile responsive ve modern arayüz
- Dark/Light Mode: Tema değiştirme desteği
- Frontend/Backend: Next.js 14 (App Router) + TypeScript
- UI Framework: Tailwind CSS
- State Management: Zustand
- Data Fetching: Tanstack Query
- Database: SQLite + Prisma ORM
- Proxy Server: Caddy v2
- Containerization: Docker + Docker Compose
- Authentication: JWT
Container'ın hangi hostname üzerinden çalışacağını belirtir. Bu değer proxy routing için kritik öneme sahiptir.
Development:
HOST=localhostProduction:
HOST=example.comRouting Mantığı:
example.com→ Dashboard'a yönlendirilirtest.example.com→ Caddy proxy ayarlarına göre yönlendirilir*.example.com→ Dinamik proxy kurallarına göre routing
proxy-manager/
├── docker-compose.yml # Docker servislerin tanımı
├── caddy/ # Caddy Server konfigürasyonu
│ ├── Caddyfile # Caddy temel config
│ ├── data/ # Caddy verileri (volumes)
│ │ ├── acme/ # SSL sertifikalar
│ │ └── logs/ # Caddy logları
│ └── config.json # Caddy REST API config
├── dashboard/ # Next.js Dashboard uygulaması
│ ├── src/
│ │ ├── app/ # Next.js App Router
│ │ │ ├── api/ # Backend API routes
│ │ │ │ ├── auth/ # Authentication endpoints
│ │ │ │ ├── proxies/ # Proxy CRUD endpoints
│ │ │ │ ├── ssl/ # SSL status endpoints
│ │ │ │ └── tokens/ # API token endpoints
│ │ │ ├── dashboard/ # Dashboard sayfaları
│ │ │ └── login/ # Login sayfası
│ │ ├── components/ # React UI bileşenleri
│ │ ├── context/ # React Context (tema, auth)
│ │ ├── lib/ # Yardımcı fonksiyonlar
│ │ └── styles/ # Tailwind tema dosyaları
│ ├── prisma/ # Prisma ORM
│ │ ├── schema.prisma # Veritabanı şeması
│ │ └── migrations/ # DB migration dosyaları
│ └── package.json # Dashboard dependencies
├── scripts/ # Yardımcı scriptler
│ ├── setup.sh # Proje kurulum
│ ├── dev-start.sh # Development başlatma
│ └── migrate.sh # Database migration
└── README.md # Bu dosya
- Docker ve Docker Compose
- Node.js 18+ (development için)
-
Projeyi klonlayın:
git clone <repo-url> cd proxy-manager
-
Environment değişkenlerini ayarlayın:
# Development için (docker-compose.yml'de varsayılan: localhost) export HOST=localhost # Production için export HOST=yourdomain.com
-
Kurulum scriptini çalıştırın:
./scripts/setup.sh
-
Uygulamayı başlatın:
docker-compose up -d
-
Dashboard'a erişin:
- Development: http://localhost
- Production: https://yourdomain.com (HOST değişkeni ile belirlenen domain)
- Caddy Admin API: http://localhost:2019
Development modunda çalışmak için:
# HOST değişkenini ayarlayın
export HOST=localhost
# Development scriptini çalıştırın
./scripts/dev-start.shBu script:
- Caddy server'ı Docker'da başlatır
- Dashboard'u development modunda (hot reload) çalıştırır
- HOST değişkenini kullanarak routing yapar
Production sunucunuzda (IP: 123.123.123.123):
# Domain'inizi ayarlayın
export HOST=example.com
export NODE_ENV=production
# Container'ı başlatın
docker-compose up -dSonuç:
example.com→ Dashboard'a yönlendirilirtest.example.com→ Proxy ayarlarınıza göre yönlendirilir- SSL sertifikaları otomatik olarak ACME ile alınır
-
Authentication
POST /api/auth/login- Kullanıcı girişiPOST /api/auth/logout- Çıkış işlemi
-
Proxy Management
GET /api/proxies- Proxy listesiPOST /api/proxies- Yeni proxy oluşturPUT /api/proxies- Proxy güncelleDELETE /api/proxies- Proxy sil
-
SSL Management
GET /api/ssl- SSL sertifika durumları
-
Token Management
GET /api/tokens- API token listesiPOST /api/tokens- Yeni token oluşturDELETE /api/tokens- Token sil
GET :2019/config/- Mevcut konfigürasyonPUT :2019/config/- Konfigürasyon güncelle
Proje SQLite veritabanı kullanır. Database işlemleri için:
# Prisma client oluştur
./scripts/migrate.sh generate
# Migration'ları uygula
./scripts/migrate.sh deploy
# Database'i sıfırla (dikkat: veri kaybolur)
./scripts/migrate.sh reset
# Seed data ekle
./scripts/migrate.sh seeddashboard/src/app/api/- Next.js API Routes (backend)dashboard/src/app/dashboard/- Dashboard sayfalarıdashboard/src/components/- Reusable React bileşenleridashboard/src/lib/- Yardımcı fonksiyonlar ve Caddy API clientdashboard/src/context/- React Context'ler (tema, auth)
- TypeScript kullanılır
- ESLint + Prettier ile kod formatting
- Tailwind CSS ile styling
- JSDoc ile fonksiyon dokümantasyonu
- Clean Code ve SOLID principles
cd dashboard
npm run test # Unit testler
npm run test:e2e # E2E testlerProduction için:
docker-compose -f docker-compose.prod.yml up -dMIT License
- Fork yapın
- Feature branch oluşturun (
git checkout -b feature/amazing-feature) - Commit yapın (
git commit -m 'Add amazing feature') - Branch'i push edin (
git push origin feature/amazing-feature) - Pull Request açın