feat(domains): 301-Weiterleitung Domain→Domain (redirect_to) — v1.2.108

Neue Domain kann per 301 auf eine andere Domain/URL umgeleitet werden, statt
auf ein Backend zu routen (Use-Case: kvs.netcell-it.de → https://zkm.netcell-it.de,
inkl. HTTPS). Variante (a): immer auf Ziel-Root (`redirect location`), pfad-
unabhängig.

- Migration 0043: domains.redirect_to text NOT NULL DEFAULT ''
- Model + domains-Service (SELECT/INSERT/UPDATE/scan)
- HAProxy-Generator: buildRedirectTo() sanitisiert (nur http(s), kein
  Whitespace/Quotes → sonst kein Redirect statt kaputter Config); Template
  emittiert `http-request redirect location <url> code 301 if hdr(host)`.
  Terminiert vor use_backend → Redirect-Domain routet auf kein Backend.
  http→https läuft über den vorhandenen :80-Redirect (zwei Hops, inkl. TLS).
- UI: Feld „Weiterleitung (301) nach" im Domain-Formular (de/en)
- Tests: Render-Zeile + buildRedirectTo-Sanitisierung

Hinweis: Die Redirect-Domain braucht weiterhin ein eigenes TLS-Zert (ACME).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Debian
2026-06-15 19:23:37 +02:00
parent f3c76f6d18
commit 79cd68e460
10 changed files with 101 additions and 10 deletions

View File

@@ -533,6 +533,8 @@
"wwwRedirectNone": "Kein Redirect",
"wwwRedirectToNaked": "→ naked (ohne www)",
"wwwRedirectToWWW": "→ www",
"redirectTo": "Weiterleitung (301) nach",
"redirectToHint": "Leitet ALLE Anfragen dieser Domain per 301 auf die Ziel-URL um (z. B. https://zkm.netcell-it.de) — immer auf die Ziel-Root. Ist es gesetzt, routet die Domain auf kein Backend. Die Domain braucht trotzdem ein eigenes TLS-Zertifikat. Leer = aus.",
"rateLimit": "Rate-Limit (pro Client-IP)",
"rateLimitHint": "Max. Requests pro Sekunde je Client-IP. HAProxy zählt über ein 10-Sekunden-Fenster pro Stick-Table (max. 100k IPs). 0 = aus.",
"maxBody": "Max. Request-Body",

View File

@@ -533,6 +533,8 @@
"wwwRedirectNone": "No redirect",
"wwwRedirectToNaked": "→ naked (no www)",
"wwwRedirectToWWW": "→ www",
"redirectTo": "Redirect (301) to",
"redirectToHint": "Redirects ALL requests for this domain with a 301 to the target URL (e.g. https://zkm.netcell-it.de) — always to the target root. When set, the domain routes to no backend. The domain still needs its own TLS certificate. Empty = off.",
"rateLimit": "Rate limit (per client IP)",
"rateLimitHint": "Max requests per second per client IP. HAProxy counts over a 10-second window per stick table (max. 100k IPs). 0 = off.",
"maxBody": "Max request body",

View File

@@ -27,6 +27,7 @@ interface Domain {
hsts_subdomains: boolean; hsts_preload: boolean
maintenance_mode: boolean; maintenance_message?: string | null
www_redirect: '' | 'to-naked' | 'to-www'
redirect_to: string
rate_limit_rps: number; max_body_kb: number
disable_h3: boolean
notes?: string | null
@@ -40,6 +41,7 @@ interface DomainFormValues {
hsts_subdomains: boolean; hsts_preload: boolean
maintenance_mode: boolean; maintenance_message?: string
www_redirect: '' | 'to-naked' | 'to-www'
redirect_to: string
rate_limit_rps: number; max_body_kb: number
disable_h3: boolean
notes?: string
@@ -272,6 +274,7 @@ export default function DomainDetailPage() {
maintenance_mode: domain.maintenance_mode,
maintenance_message: domain.maintenance_message ?? '',
www_redirect: domain.www_redirect ?? '',
redirect_to: domain.redirect_to ?? '',
rate_limit_rps: domain.rate_limit_rps ?? 0,
max_body_kb: domain.max_body_kb ?? 0,
disable_h3: domain.disable_h3 ?? false,
@@ -333,6 +336,10 @@ export default function DomainDetailPage() {
]} />
</Form.Item>
<Form.Item label={t('domains.redirectTo')} name="redirect_to" extra={t('domains.redirectToHint')}>
<Input placeholder="https://ziel-domain.de" allowClear />
</Form.Item>
<Form.Item label={t('domains.maintenance')} name="maintenance_mode" valuePropName="checked"
extra={t('domains.maintenanceHint')}>
<Switch />