jenkins-bot has submitted this change and it was merged.
Change subject: Add support for HTTP_X_FORWARDED_PROTO
......................................................................
Add support for HTTP_X_FORWARDED_PROTO
Add logic to detect when a proxy is being used in front of the
application and correct internal state accordingly so that canonical
URLs generated by the Slim framework will use the proper protocol and
port. An alternate way to correct this behavior would be to change all
of the link generation logic to use protocol relative URLs but that
would require deeper changes to the framework being used than this small
environment change shim.
Bug: 58041
Change-Id: I68731fc3a5285806360ef08fe5f4e60121c3cf3e
---
M src/Wikimania/Scholarship/App.php
1 file changed, 14 insertions(+), 0 deletions(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/Wikimania/Scholarship/App.php
b/src/Wikimania/Scholarship/App.php
index b4b57cc..1396c73 100644
--- a/src/Wikimania/Scholarship/App.php
+++ b/src/Wikimania/Scholarship/App.php
@@ -87,6 +87,20 @@
) );
});
+ // Slim does not natively understand being behind a proxy
+ // If not corrected template links created via siteUrl() may
use the wrong
+ // protocol (http instead of https).
+ if ( getenv( 'HTTP_X_FORWARDED_PROTO' ) ) {
+ $proto = getenv( 'HTTP_X_FORWARDED_PROTO' );
+ $this->slim->environment['slim.url_scheme'] = $proto;
+
+ $port = getenv( 'HTTP_X_FORWARDED_PORT' );
+ if ( $port === false ) {
+ $port = ( $proto == 'https' ) ? '443' : '80';
+ }
+ $this->slim->environment['SERVER_PORT'] = $port;
+ }
+
$this->configureIoc();
$this->configureView();
$this->configureRoutes();
--
To view, visit https://gerrit.wikimedia.org/r/99426
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I68731fc3a5285806360ef08fe5f4e60121c3cf3e
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/wikimania-scholarships
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits