Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803874
D450.id1162.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
Wed, Feb 26, 9:00 AM
Size
1 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:00 AM (10 h, 43 m)
Engine
blob
Format
Raw Data
Handle
576597
Attached To
D450: INP-1845 - Support for Nginx as a Reverse Proxy
D450.id1162.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