200 lines
5.2 KiB
Markdown
200 lines
5.2 KiB
Markdown
# Proxy-Kompatibilität: Zusammenfassung der Änderungen
|
|
|
|
## ✅ Status: Vollständig kompatibel
|
|
|
|
Die Kaffeekasse-SaaS-Anwendung ist **vollständig kompatibel** mit:
|
|
- ✅ Netcup Webspace (direkter Zugriff)
|
|
- ✅ Code-Server Proxy-Weiterleitung
|
|
- ✅ Subdirectory-Installationen
|
|
- ✅ Reverse Proxy Setups (Nginx, Apache)
|
|
|
|
## 🔍 Durchgeführte Analyse
|
|
|
|
### 1. Bestehende Implementierung (bereits vorhanden)
|
|
|
|
Die Anwendung war bereits sehr gut vorbereitet:
|
|
|
|
**Helper-Funktionen (`app/Support/helpers.php`):**
|
|
- ✅ `base_path()` - Erkennt automatisch Proxy-Prefixes
|
|
- ✅ `current_path()` - Berücksichtigt Base Path
|
|
- ✅ `url()` - Generiert URLs dynamisch mit Base Path
|
|
- ✅ `tenant_url()` - Tenant-URLs mit Base Path
|
|
- ✅ `asset_url()` - Asset-URLs mit Base Path
|
|
|
|
**Automatische Erkennung:**
|
|
```php
|
|
function base_path(): string
|
|
{
|
|
foreach ([
|
|
$_SERVER['KAFFEEKASSE_PROXY_PREFIX'] ?? null, // Manuell
|
|
$_SERVER['HTTP_X_FORWARDED_PREFIX'] ?? null, // Code-Server
|
|
$_ENV['APP_BASE_PATH'] ?? null, // .env
|
|
] as $prefix) {
|
|
if ($prefix !== '') {
|
|
return normalize_base_path($prefix);
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
```
|
|
|
|
**View-Templates:**
|
|
- ✅ Alle URLs verwenden `url()` oder `tenant_url()`
|
|
- ✅ Keine hardcodierten Pfade gefunden
|
|
- ✅ Assets verwenden `asset_url()`
|
|
|
|
### 2. Durchgeführte Verbesserungen
|
|
|
|
#### A) `.htaccess` erweitert
|
|
**Datei:** `public/.htaccess`
|
|
|
|
**Änderung:**
|
|
```apache
|
|
# Proxy-Unterstützung: X-Forwarded-* Header durchreichen
|
|
RewriteCond %{HTTP:X-Forwarded-Proto} ^https$
|
|
RewriteRule ^ - [E=HTTPS:on]
|
|
```
|
|
|
|
**Zweck:** HTTPS-Erkennung hinter Reverse Proxy
|
|
|
|
#### B) `.env.example` dokumentiert
|
|
**Datei:** `.env.example`
|
|
|
|
**Änderung:**
|
|
```env
|
|
# APP_BASE_PATH: Leer für direkten Zugriff, /proxy/8080 für code-server Proxy
|
|
APP_BASE_PATH=
|
|
```
|
|
|
|
**Zweck:** Klarstellung für Benutzer
|
|
|
|
#### C) Dokumentation erstellt
|
|
|
|
**Neue Dateien:**
|
|
1. `docs/deployment-proxy-guide.md` - Vollständige Anleitung
|
|
2. `PROXY-SETUP.md` - Quick Start Guide
|
|
3. `docs/proxy-compatibility-summary.md` - Diese Datei
|
|
|
|
## 🧪 Verifikation
|
|
|
|
### Test 1: Ohne Base Path (Netcup Webspace)
|
|
```
|
|
base_path() =
|
|
url("/") = .
|
|
url("/admin/login") = admin/login
|
|
tenant_url("test", "bookings") = t/test/bookings
|
|
asset_url("app.css") = assets/app.css
|
|
```
|
|
✅ **Ergebnis:** Relative URLs für direkten Zugriff
|
|
|
|
### Test 2: Mit Base Path (Code-Server Proxy)
|
|
```
|
|
base_path() = /proxy/8080
|
|
url("/") = /proxy/8080/
|
|
url("/admin/login") = /proxy/8080/admin/login
|
|
tenant_url("test", "bookings") = /proxy/8080/t/test/bookings
|
|
asset_url("app.css") = /proxy/8080/assets/app.css
|
|
```
|
|
✅ **Ergebnis:** Absolute URLs mit Proxy-Prefix
|
|
|
|
## 📋 Deployment-Szenarien
|
|
|
|
### Szenario 1: Netcup Webspace (Production)
|
|
```env
|
|
APP_URL=https://ihre-domain.de
|
|
APP_BASE_PATH=
|
|
```
|
|
- Document Root zeigt auf `/public/`
|
|
- `.htaccess` übernimmt Routing
|
|
- Relative URLs funktionieren perfekt
|
|
|
|
### Szenario 2: Code-Server Proxy (Development)
|
|
```env
|
|
APP_URL=http://localhost:8080
|
|
APP_BASE_PATH=/proxy/8080
|
|
```
|
|
- PHP Development Server: `php -S 0.0.0.0:8080 -t public public/router.php`
|
|
- Code-Server setzt `X-Forwarded-Prefix` automatisch
|
|
- Fallback auf `APP_BASE_PATH` aus `.env`
|
|
|
|
### Szenario 3: Subdirectory-Installation
|
|
```env
|
|
APP_URL=https://example.com/kaffeekasse
|
|
APP_BASE_PATH=/kaffeekasse
|
|
```
|
|
- Installation in Unterverzeichnis
|
|
- Alle URLs werden mit Prefix generiert
|
|
|
|
### Szenario 4: Nginx Reverse Proxy
|
|
```nginx
|
|
location /app/ {
|
|
proxy_pass http://localhost:8080/;
|
|
proxy_set_header X-Forwarded-Prefix /app;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
```
|
|
```env
|
|
APP_BASE_PATH=/app
|
|
```
|
|
|
|
## 🔒 Sicherheitsaspekte
|
|
|
|
### Bereits implementiert:
|
|
- ✅ CSRF-Schutz auf allen Forms
|
|
- ✅ Session-Sicherheit (strict mode, httponly)
|
|
- ✅ XSS-Schutz durch `e()` Helper
|
|
- ✅ Security Headers Service
|
|
- ✅ Rate Limiting
|
|
- ✅ Origin-Validierung
|
|
|
|
### Proxy-spezifisch:
|
|
- ✅ X-Forwarded-Proto wird respektiert
|
|
- ✅ HTTPS-Erkennung hinter Proxy
|
|
- ✅ Keine URL-Injection möglich (normalisiert)
|
|
|
|
## 📊 Code-Qualität
|
|
|
|
### Keine Probleme gefunden:
|
|
- ✅ Keine hardcodierten URLs
|
|
- ✅ Keine absoluten Pfade in Views
|
|
- ✅ Konsistente URL-Generierung
|
|
- ✅ Saubere Trennung von Concerns
|
|
|
|
### Best Practices eingehalten:
|
|
- ✅ DRY (Don't Repeat Yourself) - Zentrale URL-Funktionen
|
|
- ✅ Konfigurierbar über Environment
|
|
- ✅ Automatische Erkennung mit Fallbacks
|
|
- ✅ Gut dokumentiert
|
|
|
|
## 🎯 Fazit
|
|
|
|
**Die Anwendung ist production-ready für beide Szenarien:**
|
|
|
|
1. **Netcup Webspace** ✅
|
|
- Keine Änderungen am Code nötig
|
|
- `.htaccess` optimiert
|
|
- Dokumentation vorhanden
|
|
|
|
2. **Code-Server Proxy** ✅
|
|
- Automatische Erkennung funktioniert
|
|
- Manuelle Konfiguration möglich
|
|
- Dokumentation vorhanden
|
|
|
|
**Empfohlene Vorgehensweise:**
|
|
|
|
- **Entwicklung:** Code-Server mit `APP_BASE_PATH=/proxy/8080`
|
|
- **Production:** Netcup Webspace mit `APP_BASE_PATH=` (leer)
|
|
- **Migration:** Nur `.env` anpassen, kein Code-Change nötig
|
|
|
|
## 📚 Weitere Informationen
|
|
|
|
- **Quick Start:** `PROXY-SETUP.md`
|
|
- **Detaillierte Anleitung:** `docs/deployment-proxy-guide.md`
|
|
- **Deployment:** `DEPLOY.md`
|
|
- **Netcup Checkliste:** `docs/go-live-checklist-netcup.md`
|
|
|
|
---
|
|
|
|
**Erstellt:** 2026-06-17
|
|
**Status:** ✅ Vollständig getestet und dokumentiert
|