Skip to content

Commit 835ed09

Browse files
committed
Fix: Polishing
1 parent 6e344fb commit 835ed09

17 files changed

+1994
-121
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ STORAGE_CONFIG=/app/config/storage.yml
2929
ADMIN_API_KEYS=your_admin_key_1,your_admin_key_2
3030
RENDIFF_API_KEYS=your_client_key_1,your_client_key_2,your_client_key_3
3131
ENABLE_API_KEYS=true
32-
CORS_ORIGINS=*
32+
CORS_ORIGINS=https://localhost,http://localhost
3333

3434
# SSL/HTTPS Configuration (for production)
3535
DOMAIN_NAME=localhost
@@ -48,4 +48,4 @@ MAX_CONCURRENT_JOBS_PER_KEY=10
4848
MAX_JOB_DURATION=21600
4949

5050
# External URLs
51-
EXTERNAL_URL=http://localhost:8080
51+
EXTERNAL_URL=https://localhost

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,21 @@ CLEANUP_SUMMARY.md
4848
# Storage and uploads
4949
/storage/
5050
/uploads/
51+
52+
# SSL certificates (keep generation script)
53+
traefik/certs/*.crt
54+
traefik/certs/*.key
55+
traefik/certs/*.csr
56+
traefik/certs/*.pem
57+
traefik/letsencrypt/
58+
traefik/acme/
59+
60+
# Test results and monitoring
61+
test-results/
62+
monitoring/ssl-scan-results/
63+
monitoring/*.log
64+
65+
# Backups
66+
backups/
67+
*.backup
68+
backup-*/

README.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ cd ffmpeg-api
3535
./setup.sh --development # Quick local development
3636
./setup.sh --standard # Production (PostgreSQL, Redis, monitoring)
3737
./setup.sh --genai # AI-enhanced (GPU support, AI models)
38-
./setup.sh --production # Interactive production wizard
38+
./setup.sh --interactive # Interactive setup wizard
3939
```
4040

41-
**That's it!** Your API will be running at `http://localhost:8080`
41+
**That's it!** Your API will be running at:
42+
- Development: `http://localhost:8000`
43+
- Production: `https://localhost` (HTTPS with self-signed certificate)
4244

4345
### 🏃‍♂️ Development (60 seconds)
4446
Perfect for testing and local development:
@@ -54,7 +56,7 @@ Enterprise-ready deployment:
5456
```bash
5557
./setup.sh --standard
5658
```
57-
**Features:** PostgreSQL, Redis, monitoring, API keys, 2 CPU workers
59+
**Features:** PostgreSQL, Redis, monitoring, API keys, HTTPS by default, 2 CPU workers
5860

5961
### 🤖 AI-Enhanced Production
6062
GPU-accelerated AI features:
@@ -72,6 +74,7 @@ GPU-accelerated AI features:
7274
| **Database** | SQLite | PostgreSQL | PostgreSQL |
7375
| **Queue** | Redis | Redis | Redis |
7476
| **Authentication** | Disabled | API Keys | API Keys |
77+
| **HTTPS/SSL** || ✅ (Self-signed + Let's Encrypt) | ✅ (Self-signed + Let's Encrypt) |
7578
| **Monitoring** | Basic | Full (Prometheus/Grafana) | Full |
7679
| **Workers** | 1 CPU | 2 CPU | 2 CPU + 1 GPU |
7780
| **AI Features** ||||
@@ -121,19 +124,50 @@ GET /docs # Interactive API documentation
121124
# List current keys (masked)
122125
./scripts/manage-api-keys.sh list
123126

124-
# Test API access
125-
curl -H "X-API-Key: your-key" http://localhost:8080/api/v1/health
127+
# Test API access (development)
128+
curl -H "X-API-Key: your-key" http://localhost:8000/api/v1/health
129+
130+
# Test API access (production - HTTPS)
131+
curl -k -H "X-API-Key: your-key" https://localhost/api/v1/health
126132
```
127133

128134
### HTTPS/SSL Setup
135+
136+
**🔒 HTTPS is enabled by default in ALL production deployments** with self-signed certificates.
137+
138+
#### SSL Certificate Options:
139+
140+
**Self-signed (Default)** - Works immediately:
141+
```bash
142+
./setup.sh --standard # HTTPS ready with self-signed cert
143+
```
144+
145+
**Let's Encrypt (Production)** - Free trusted certificates:
129146
```bash
130147
# Configure your domain
131148
export DOMAIN_NAME=api.yourdomain.com
132149
133150

134-
# Setup with automatic SSL
135-
./setup.sh --production
136-
# Choose HTTPS option for Let's Encrypt certificates
151+
# Setup with Let's Encrypt
152+
./setup.sh --interactive # Choose HTTPS option during setup
153+
```
154+
155+
**Commercial SSL** - EV/OV certificates:
156+
```bash
157+
# Install commercial certificate
158+
./scripts/enhanced-ssl-manager.sh install-commercial cert.crt private.key
159+
```
160+
161+
**Comprehensive SSL Management:**
162+
```bash
163+
# Show all SSL management options
164+
./scripts/enhanced-ssl-manager.sh --help
165+
166+
# Monitor SSL certificates
167+
./scripts/enhanced-ssl-manager.sh monitor-start
168+
169+
# Test SSL configuration
170+
./scripts/enhanced-ssl-manager.sh test-ssl yourdomain.com
137171
```
138172

139173
### Monitoring & Health
@@ -208,8 +242,8 @@ docker-compose logs -f api
208242
| **[Setup Guide](docs/SETUP.md)** | Complete setup documentation for all deployment types |
209243
| **[API Reference](docs/API.md)** | Detailed API endpoint documentation |
210244
| **[Installation Guide](docs/INSTALLATION.md)** | Advanced installation and configuration |
211-
| **[Deployment Guide](DEPLOYMENT.md)** | Production deployment best practices |
212-
| **[Security Guide](SECURITY.md)** | Security configuration and best practices |
245+
| **[Production Setup](docs/SETUP.md#production-setup)** | Production deployment best practices |
246+
| **[HTTPS/SSL Setup](docs/SETUP.md#httpssl-configuration)** | Security configuration and best practices |
213247

214248
## 🎯 Use Cases
215249

@@ -300,12 +334,12 @@ Supports deployment on:
300334
- **📚 Documentation**: Complete guides in `/docs`
301335
- **🐛 Issues**: [GitHub Issues](https://github.com/rendiffdev/ffmpeg-api/issues)
302336
- **💬 Discussions**: [GitHub Discussions](https://github.com/rendiffdev/ffmpeg-api/discussions)
303-
- **🔒 Security**: See [SECURITY.md](SECURITY.md)
337+
- **🔒 Security**: See [HTTPS/SSL Configuration](docs/SETUP.md#httpssl-configuration)
304338
- **📄 License**: [MIT License](LICENSE)
305339

306340
## 🤝 Contributing
307341

308-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
342+
We welcome contributions! Please open an issue or submit a pull request on our [GitHub repository](https://github.com/rendiffdev/ffmpeg-api).
309343

310344
## 📄 License
311345

api/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Settings(BaseSettings):
6565
ADMIN_API_KEYS: str = "" # Comma-separated list of admin API keys
6666

6767
# CORS
68-
CORS_ORIGINS: List[str] = Field(default_factory=lambda: ["*"])
68+
CORS_ORIGINS: List[str] = Field(default_factory=lambda: ["http://localhost", "https://localhost"])
6969

7070
# Monitoring
7171
ENABLE_METRICS: bool = True

docker-compose.prod.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ services:
1111
dockerfile: docker/api/Dockerfile
1212
container_name: rendiff-api
1313
restart: unless-stopped
14-
ports:
15-
- "${API_PORT:-8080}:8080"
14+
# Ports handled by Traefik - no direct exposure needed
1615
environment:
1716
# Basic Configuration
1817
- API_HOST=0.0.0.0
19-
- API_PORT=8080
18+
- API_PORT=8000
2019
- API_WORKERS=${API_WORKERS:-4}
21-
- EXTERNAL_URL=${EXTERNAL_URL:-http://localhost:8080}
20+
- EXTERNAL_URL=${EXTERNAL_URL:-https://localhost}
2221

2322
# Database
2423
- DATABASE_URL=${DATABASE_URL}
@@ -50,7 +49,7 @@ services:
5049
redis:
5150
condition: service_healthy
5251
healthcheck:
53-
test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"]
52+
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health"]
5453
interval: 30s
5554
timeout: 10s
5655
retries: 3
@@ -68,12 +67,12 @@ services:
6867
labels:
6968
# Enable Traefik for this service
7069
- "traefik.enable=true"
71-
- "traefik.http.routers.api.rule=Host(`${DOMAIN_NAME:-localhost}`)"
70+
- "traefik.http.routers.api.rule=Host(`${DOMAIN_NAME:-localhost}`) && PathPrefix(`/`)"
7271
- "traefik.http.routers.api.entrypoints=websecure"
73-
- "traefik.http.routers.api.tls.certresolver=${CERT_RESOLVER:-letsencrypt}"
72+
- "traefik.http.routers.api.tls=true"
7473
- "traefik.http.routers.api.service=api"
7574
- "traefik.http.routers.api.middlewares=api-middleware"
76-
- "traefik.http.services.api.loadbalancer.server.port=8080"
75+
- "traefik.http.services.api.loadbalancer.server.port=8000"
7776
- "traefik.http.services.api.loadbalancer.healthcheck.path=/api/v1/health"
7877
- "traefik.http.middlewares.api-middleware.chain.middlewares=security-headers,api-rate-limit,compression"
7978

@@ -258,7 +257,7 @@ services:
258257
- "traefik.enable=true"
259258
- "traefik.http.routers.prometheus.rule=Host(`prometheus.${DOMAIN_NAME:-localhost}`)"
260259
- "traefik.http.routers.prometheus.entrypoints=websecure"
261-
- "traefik.http.routers.prometheus.tls.certresolver=${CERT_RESOLVER:-letsencrypt}"
260+
- "traefik.http.routers.prometheus.tls=true"
262261
- "traefik.http.routers.prometheus.service=prometheus"
263262
- "traefik.http.routers.prometheus.middlewares=security-headers"
264263
- "traefik.http.services.prometheus.loadbalancer.server.port=9090"
@@ -302,7 +301,7 @@ services:
302301
- "traefik.enable=true"
303302
- "traefik.http.routers.grafana.rule=Host(`grafana.${DOMAIN_NAME:-localhost}`)"
304303
- "traefik.http.routers.grafana.entrypoints=websecure"
305-
- "traefik.http.routers.grafana.tls.certresolver=${CERT_RESOLVER:-letsencrypt}"
304+
- "traefik.http.routers.grafana.tls=true"
306305
- "traefik.http.routers.grafana.service=grafana"
307306
- "traefik.http.routers.grafana.middlewares=security-headers"
308307
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
@@ -317,11 +316,12 @@ services:
317316
ports:
318317
- "${TRAEFIK_HTTP_PORT:-80}:80"
319318
- "${TRAEFIK_HTTPS_PORT:-443}:443"
320-
- "${TRAEFIK_DASHBOARD_PORT:-8080}:8080"
319+
- "${TRAEFIK_DASHBOARD_PORT:-8081}:8080"
321320
volumes:
322321
- /var/run/docker.sock:/var/run/docker.sock:ro
323322
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
324323
- ./traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
324+
- ./traefik/certs:/etc/traefik/certs:ro
325325
- traefik_ssl_data:/letsencrypt
326326
- traefik_logs:/var/log/traefik
327327
environment:
@@ -344,16 +344,15 @@ services:
344344
reservations:
345345
memory: 128M
346346
cpus: '0.1'
347-
profiles:
348-
- traefik
347+
# No profile - Traefik runs by default for HTTPS
349348
networks:
350349
- rendiff-network
351350
labels:
352351
# Enable Traefik for the dashboard
353352
- "traefik.enable=true"
354353
- "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.${DOMAIN_NAME:-localhost}`)"
355354
- "traefik.http.routers.traefik-dashboard.entrypoints=websecure"
356-
- "traefik.http.routers.traefik-dashboard.tls.certresolver=${CERT_RESOLVER:-letsencrypt}"
355+
- "traefik.http.routers.traefik-dashboard.tls=true"
357356
- "traefik.http.routers.traefik-dashboard.service=api@internal"
358357

359358
volumes:

docker-compose.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,51 @@ services:
1919
networks:
2020
- rendiff
2121

22-
# API Gateway
22+
# Traefik Reverse Proxy with HTTPS (runs by default)
23+
traefik:
24+
image: traefik:v3.0
25+
container_name: rendiff_traefik
26+
command:
27+
- --configFile=/etc/traefik/traefik.yml
28+
ports:
29+
- "80:80"
30+
- "443:443"
31+
- "8081:8080" # Dashboard on 8081 to avoid conflict
32+
volumes:
33+
- /var/run/docker.sock:/var/run/docker.sock:ro
34+
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
35+
- ./traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
36+
- ./traefik/certs:/etc/traefik/certs:ro
37+
depends_on:
38+
- api
39+
networks:
40+
- rendiff
41+
restart: unless-stopped
42+
labels:
43+
- "traefik.enable=true"
44+
- "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.localhost`)"
45+
- "traefik.http.routers.traefik-dashboard.entrypoints=websecure"
46+
- "traefik.http.routers.traefik-dashboard.tls=true"
47+
- "traefik.http.routers.traefik-dashboard.service=api@internal"
48+
49+
# API Gateway (now behind Traefik)
2350
krakend:
2451
image: devopsfaith/krakend:2.6
2552
container_name: rendiff_gateway
2653
volumes:
2754
- ./config/krakend.json:/etc/krakend/krakend.json:ro
28-
ports:
29-
- "8080:8080"
55+
# No port exposure - accessed through Traefik
3056
depends_on:
3157
- api
3258
networks:
3359
- rendiff
3460
restart: unless-stopped
61+
labels:
62+
- "traefik.enable=true"
63+
- "traefik.http.routers.krakend.rule=Host(`localhost`) && PathPrefix(`/`)"
64+
- "traefik.http.routers.krakend.entrypoints=websecure"
65+
- "traefik.http.routers.krakend.tls=true"
66+
- "traefik.http.services.krakend.loadbalancer.server.port=8080"
3567

3668
# Database Service
3769
postgres:

docker/traefik/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM traefik:v3.0
2+
3+
# Install OpenSSL for certificate generation
4+
RUN apk add --no-cache openssl
5+
6+
# Create directories
7+
RUN mkdir -p /etc/traefik/certs
8+
9+
# Copy certificate generation script
10+
COPY traefik/certs/generate-self-signed.sh /generate-cert.sh
11+
RUN chmod +x /generate-cert.sh
12+
13+
# Generate self-signed certificate if not exists
14+
RUN if [ ! -f /etc/traefik/certs/cert.crt ]; then \
15+
cd /etc/traefik/certs && \
16+
/generate-cert.sh; \
17+
fi
18+
19+
# Entry point
20+
ENTRYPOINT ["/entrypoint.sh"]
21+
CMD ["traefik"]

0 commit comments

Comments
 (0)