Skip to content

location: fix broken redirects behind reverse proxy (https://host:80)#279

Open
Avatarsia wants to merge 1 commit into
OpenXE-org:masterfrom
Avatarsia:fix/location-redirect-proxy-port
Open

location: fix broken redirects behind reverse proxy (https://host:80)#279
Avatarsia wants to merge 1 commit into
OpenXE-org:masterfrom
Avatarsia:fix/location-redirect-proxy-port

Conversation

@Avatarsia

Copy link
Copy Markdown
Contributor

Problem

Location::__construct() (www/lib/class.location.php) baut die absolute Redirect-URL aus SERVER_NAME und SERVER_PORT und haengt den Port immer an:

$server = $REQUEST_PROTOCOL.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];

Hinter einem TLS-terminierenden Reverse Proxy (nginx/openresty → Backend auf Port 80, X-Forwarded-Proto: https) zeigt damit jeder Location:-Redirect (z.B. nach Artikel einlagern) auf:

https://host:80/www/index.php?module=artikel&action=lager&id=...&msgs=...

Der Browser macht einen TLS-Handshake gegen den Klartext-HTTP-Port → SSL-Fehler. Fuer den Anwender sieht das wie ein ungueltiges Zertifikat aus, obwohl Zertifikat und Server in Ordnung sind.

Fix

HTTP_HOST bevorzugen — enthaelt Host und ggf. Port exakt so, wie der Client sie adressiert hat (gleiches Muster wie der bereits vorhandene Nginx-"_"-Sonderfall eine Zeile darueber). Fallback auf SERVER_NAME nur noch, wenn HTTP_HOST fehlt, und dort SERVER_PORT nur bei Nicht-Standard-Ports anhaengen (gleiches Muster wie der SERVER_ADDR-Zweig darunter).

Verifikation

Standalone-Test der Klasse mit gemocktem $app, 8 Szenarien (getServer() + getLocationUrl()):

Szenario vorher nachher
Proxy: XFP=https, Backend-Port 80 https://host:80/... https://host/...
Direkt HTTP :80 http://host:80/... http://host/...
Direkt HTTPS :443 https://host:443/... https://host/...
Nicht-Standard-Port 8080 http://host:8080/... http://host:8080/...
Ohne HTTP_HOST (Fallback) :80 / :8080 :80 ❌ / :8080 ohne Port ✅ / :8080
Nginx SERVER_NAME="_" ✅ (unveraendert)

php -l sauber. Reproduziert und verifiziert auf produktiver Instanz hinter openresty.

🤖 Generated with Claude Code

Location::__construct() built the absolute redirect URL from
SERVER_NAME and SERVER_PORT, always appending the port. Behind a
TLS-terminating reverse proxy (nginx/openresty -> backend on port 80,
X-Forwarded-Proto: https) every Location redirect pointed to
https://host:80/... - the browser then attempts a TLS handshake
against the plain-HTTP port and fails with an SSL error.

Prefer HTTP_HOST (host and port exactly as the client addressed
them, same as the existing nginx "_" special case) and only fall
back to SERVER_NAME, appending SERVER_PORT solely for non-standard
ports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Avatarsia pushed a commit to Avatarsia/OpenXE that referenced this pull request Jun 10, 2026
…nches

Upstream PR OpenXE-org#279 - Location redirects behind a TLS-terminating reverse
proxy pointed to https://host:80/... causing SSL errors after actions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Avatarsia pushed a commit to Avatarsia/OpenXE that referenced this pull request Jun 10, 2026
…nches

Upstream PR OpenXE-org#279 - Location redirects behind a TLS-terminating reverse
proxy pointed to https://host:80/... causing SSL errors after actions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Avatarsia

Copy link
Copy Markdown
Contributor Author

Lokal getestet und damit ist es nicht mehr notwendig in den Settings, den Server anzugeben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant