http: Don't set X-Forwarded-Proto when using a reverse proxy

Discussion on Ia16d8f86b1cb20 indicates that we want to go in the other
direction - MediaWiki shouldn't set X-Forwarded-Proto, rather the
reverse proxy (envoy in Wikimedia's case) should set it.

This follows-up cc241c2add.

Bug: T288848
Change-Id: Ifc5e9da9a02b45d9d1ad51c3e1389f9ac7325c86
This commit is contained in:
Kunal Mehta 2021-11-16 10:44:08 -08:00 committed by Krinkle
parent f06bf93152
commit bfad87aae8
2 changed files with 0 additions and 4 deletions

View file

@ -264,9 +264,6 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
}
// Set the current host in the Host header
$this->setHeader( 'Host', $this->parsedUrl['host'] );
// Set current protocol in X-Forwarded-Proto
// TODO: consider supporting the standardized "Forwarded" header too
$this->setHeader( 'X-Forwarded-Proto', $this->parsedUrl['scheme'] );
// Replace scheme, host and port in the request
$this->parsedUrl['scheme'] = $parsedProxy['scheme'];
$this->parsedUrl['host'] = $parsedProxy['host'];

View file

@ -94,7 +94,6 @@ class MWHttpRequestTest extends PHPUnit\Framework\TestCase {
$req->setReverseProxy( 'http://localhost:1234' );
$this->assertSame( 'http://localhost:1234/path?query=string', $req->url );
$this->assertSame( 'example.org', $req->reqHeaders['Host'] );
$this->assertSame( 'https', $req->reqHeaders['X-Forwarded-Proto'] );
}
}