Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F802588
D450.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 8:01 PM
Size
1 KB
Mime Type
text/x-diff
Expires
Tue, Feb 25, 8:01 PM (18 h, 15 m)
Engine
blob
Format
Raw Data
Handle
575487
Attached To
D450: INP-1845 - Support for Nginx as a Reverse Proxy
D450.diff
View Options
Index: core/kernel/startup.php
===================================================================
--- core/kernel/startup.php
+++ core/kernel/startup.php
@@ -39,8 +39,15 @@
define('ADMIN_DIRECTORY', $vars['AdminDirectory']);
define('ADMIN_PRESETS_DIRECTORY', $vars['AdminPresetsDirectory']);
- $https_mark = getArrayValue($_SERVER, 'HTTPS');
- define('PROTOCOL', ($https_mark == 'on') || ($https_mark == '1') ? 'https://' : 'http://');
+ if ( array_key_exists('HTTP_NGINX_PROTO', $_SERVER) ) {
+ define('NGINX_PROTOCOL_OVERRIDE', true);
+ define('PROTOCOL', $_SERVER['HTTP_NGINX_PROTO'] === 'https' ? 'https://' : 'http://');
+ }
+ else {
+ define('NGINX_PROTOCOL_OVERRIDE', false);
+ $https_mark = getArrayValue($_SERVER, 'HTTPS');
+ define('PROTOCOL', ($https_mark == 'on') || ($https_mark == '1') ? 'https://' : 'http://');
+ }
if ( isset($_SERVER['HTTP_HOST']) ) {
// accessed from browser
@@ -54,14 +61,16 @@
$port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : false;
- if ($port) {
- if ( (PROTOCOL == 'http://' && $port != '80') || (PROTOCOL == 'https://' && $port != '443') ) {
- // if non-standard port is used, then define it
- define('PORT', $port);
+ if ( $port ) {
+ if ( !NGINX_PROTOCOL_OVERRIDE
+ && ((PROTOCOL == 'http://' && $port != '80') || (PROTOCOL == 'https://' && $port != '443'))
+ ) {
+ // If non-standard port is used, then define it.
+ define('PORT', $port);
}
$http_host = preg_replace('/:' . $port . '$/', '', $http_host);
- }
+ }
define('SERVER_NAME', $http_host);
Event Timeline
Log In to Comment