Skip to content

Suggestion change scheme calculation to enable use behind SSL reverse proxy #398

@monty241

Description

@monty241

In branch koppelting HyphaRequest.php it reads:

                public function getScheme() {
                        // Apache 2.4+ has REQUEST_SCHEME
                        if (array_key_exists('REQUEST_SCHEME', $_SERVER))
                                return $_SERVER['REQUEST_SCHEME'];
                        if (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on')
                                return 'https';
                        return 'http';
                }

In master it reads:

		public function getScheme() {
			// Apache 2.4+ has REQUEST_SCHEME
			if (array_key_exists('REQUEST_SCHEME', $_SERVER))
				return $_SERVER['REQUEST_SCHEME'];
			if ($this->isSecure())
				return 'https';
			return 'http';
		}

However, REQUEST_SCHEME is set by the rewrite module of Apache 2. This makes it impossible to set REQUEST_SCHEME from the Apache configuration, such as based upon yes/no X-Forward headers present or hard coded.

HTTPS variable is not set by rewrite module. There suggested change is to use:

                public function getScheme() {
                        if (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on')
                                return 'https';
                        // Apache 2.4+ has REQUEST_SCHEME
                        if (array_key_exists('REQUEST_SCHEME', $_SERVER))
                                return $_SERVER['REQUEST_SCHEME'];
                        return 'http';
                }

so it is possible to use HTTP behind a HTTPS reverse proxy as in apache2.conf:

#
# Hypha.
#
<VirtualHost *:8080>
  ServerName destadsbron.invantive.com
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/hypha
  LogLevel info
  ErrorLog /dev/stderr
  CustomLog /dev/stdout combined
  DirectoryIndex index.php
  SetEnv HTTPS on
</VirtualHost>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions