BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/99426


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, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/wikimania-scholarships 
refs/changes/26/99426/1

diff --git a/src/Wikimania/Scholarship/App.php 
b/src/Wikimania/Scholarship/App.php
index b4b57cc..d730c09 100644
--- a/src/Wikimania/Scholarship/App.php
+++ b/src/Wikimania/Scholarship/App.php
@@ -87,6 +87,17 @@
                        ) );
                });
 
+               // 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;
+                       if ( $proto = 'https' ) {
+                               $this->slim->environment['SERVER_PORT'] = '443';
+                       }
+               }
+
                $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: newchange
Gerrit-Change-Id: I68731fc3a5285806360ef08fe5f4e60121c3cf3e
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/wikimania-scholarships
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to