Issue Bug Closed

#33667ad link composition with Typo3 reverse proxy and ssl (https)

Phlegx Systems 02/03/12, 19:18 updated 06/15/15, 10:27

Description

The function viewOnClick($pageId, $rootLine = NULL) in typo3_src/t3lib/class.t3lib_befunc.php returns a bad link if in Typo3 is configured a reverse proxy with ssl for the backend.

Configuration

- system: Typo3 4.5.3
- backend: reverseProxy and HTTPS
- frontend: no reverseProxy and only HTTP

This Typo3 config is given:

[SYS][reverseProxyIP] = 00.00.00.00 my IP
[SYS][reverseProxyHeaderMultiValue] = first
SYS][reverseProxyPrefix] =
[SYS][reverseProxySSL] = *
[SYS][reverseProxyPrefixSSL] = /mydomain.com
[BE][lockSSL] = 1

Scenario

If one uses this code for a backend extension:

https://mydomain.com/… [^]

INSTEAD OF

https://reverse-proxy.com/mydomain.com/… [^]

Solution (alpha)

I have check the Typo3 typo3_src/t3lib/class.t3lib_befunc.php code on

line 2908:
$viewDomain = self::getViewDomain($pageUid, $rootLine);

line 2936-2937:
$protocol = t3lib_div::getIndpEnv(‘TYPO3_SSL’) ? ‘https://’ ] : ‘http://’; [
$domain = $protocol . self::firstDomainRecord($rootLine);

and found that Typo3 don’t respect the reverse proxy and ssl config. In other words, it respects the ssl config and adds the https protocol right but don’t adds the reverse proxy in the link.

I have add this code after line 2937 to solve the problem:

if (!($_SERVER['HTTP_X_FORWARDED_HOST'] == '' || $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'] == '')) {
                    $host = t3lib_div::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_HOST']);
                    if (count($host)) {
                        switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) {
                            case 'last':
                                $host = array_pop($host);
                                break;
                            case 'first':
                                $host = array_shift($host);
                                break;
                            case 'none':
                            default:
                                $host = '';
                                break;
                        }
                    }
                    $domain = $protocol . $_SERVER['HTTP_X_FORWARDED_HOST'] . $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'];
                }

Other

With reverseProxy, SSL configured in Typo3 and without this bug repair, many links generated with t3lib_BEfunc::viewOnClick in extensions (direct_mail) or Typo3 core are broken.

Typo3 backend API broken link example:

On the backend, if I select a page in the pagetree and then make a right click and click on page preview the html contains the bad https url without the reverse proxy information.

What about if one uses reverseProxy and/or SSL (https) in frontend and backend? Do we have to introduce a new Typo3 config variable like [SYS][reverseProxySSLLocation] that can be 1 (only backend), 2 (backend and frontend),…

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.