# Multi-Tenant furt Setup-Anleitung ## Installation ### 1. Dateien platzieren ```bash # OpenBSD/FreeBSD mkdir -p /usr/local/etc/furt mkdir -p /usr/local/share/furt # Oder Linux mkdir -p /etc/furt mkdir -p /usr/local/share/furt # Source code cp -r src/ /usr/local/share/furt/ cp -r config/ /usr/local/share/furt/ ``` ### 2. Konfiguration erstellen ```bash # Beispiel-Config kopieren und anpassen # OpenBSD/FreeBSD: cp furt.conf.example /usr/local/etc/furt/furt.conf # Linux: cp furt.conf.example /etc/furt/furt.conf # Config editieren vi /usr/local/etc/furt/furt.conf # oder /etc/furt/furt.conf ``` ### 3. Start-Script ```bash #!/bin/sh # /usr/local/bin/furt cd /usr/local/share/furt lua src/main.lua ``` ## Multi-Tenant Konfiguration ### Beispiel für 3 Websites ```ini [server] host = 127.0.0.1 port = 8080 [smtp_default] host = mail.dragons-at-work.de port = 465 user = noreply@dragons-at-work.de password = your-smtp-password # Website 1: Dragons@Work [api_key "daw-key-abc123"] name = "Dragons@Work Website" permissions = mail:send allowed_ips = 1.2.3.4/32, 10.0.0.0/8 mail_to = admin@dragons-at-work.de mail_from = noreply@dragons-at-work.de mail_subject_prefix = "[DAW] " # Website 2: Biocodie (gleiche SMTP, andere Empfänger) [api_key "bio-key-def456"] name = "Biocodie Website" permissions = mail:send allowed_ips = 5.6.7.8/32 mail_to = contact@biocodie.de mail_from = noreply@biocodie.de mail_subject_prefix = "[Biocodie] " # Website 3: Kunde mit eigenem SMTP [api_key "kunde-key-ghi789"] name = "Kunde X Website" permissions = mail:send allowed_ips = 9.10.11.12/32 mail_to = info@kunde-x.de mail_from = noreply@kunde-x.de mail_smtp_host = mail.kunde-x.de mail_smtp_user = noreply@kunde-x.de mail_smtp_pass = kunde-smtp-password ``` ## Admin-Workflow ### Neue Website hinzufügen 1. **Config editieren:** ```bash vi /usr/local/etc/furt/furt.conf ``` 2. **Neuen API-Key-Block hinzufügen:** ```ini [api_key "neue-website-key"] name = "Neue Website" permissions = mail:send allowed_ips = 12.34.56.78/32 mail_to = contact@neue-website.de mail_from = noreply@neue-website.de ``` 3. **furt neu starten:** ```bash systemctl restart furt # oder pkill -f "lua.*main.lua" && /usr/local/bin/furt & ``` ### Website testen ```bash # Test mit curl curl -X POST http://localhost:8080/v1/mail/send \ -H "X-API-Key: neue-website-key" \ -H "Content-Type: application/json" \ -d '{ "name": "Test User", "email": "test@example.com", "subject": "Test Message", "message": "This is a test message" }' ``` ## Vorteile des Multi-Tenant-Systems ### ✅ Ein Server, viele Websites - Alle Websites nutzen eine furt-Instanz - Jede Website hat eigenen API-Key - Verschiedene Empfänger-Adressen - Verschiedene SMTP-Server möglich ### ✅ Admin-freundlich - Nginx-style Config-Format - Einfach neue Websites hinzufügen - Klare Struktur pro Website - Kommentare möglich ### ✅ Sicher - IP-Restrictions pro Website - Permissions pro API-Key - Separate SMTP-Credentials möglich - Rate-Limiting bleibt erhalten ### ✅ Flexibel - Default SMTP + website-spezifische SMTP - Subject-Prefix pro Website - Verschiedene Mail-Adressen - Beliebig viele Websites ## Backward Compatibility Das neue System ist **vollständig kompatibel** mit der alten config/server.lua API. Bestehende Module (auth.lua, main.lua, etc.) funktionieren ohne Änderungen. ## Troubleshooting ### Config-Parsing-Fehler ```bash # Config-Syntax prüfen lua -e "require('src.config_parser').parse_file('/usr/local/etc/furt/furt.conf')" ``` ### Mail-Routing testen ```bash # Logs anschauen tail -f /var/log/furt.log # Debug-Mode FURT_DEBUG=true lua src/main.lua ```