ZF2-508: Return proper server host name when behind a proxy

Issue Type: Patch Created: 2012-08-29T20:27:49.000+0000 Last Updated: 2012-10-08T20:14:46.000+0000 Status: Closed Fix version(s): Reporter: Raymond (rkolbe) Assignee: John Kelly (postalservice14) Tags: - Zend\View

  • helper
  • proxy
  • server
  • view

Related issues: Attachments:


\Zend\View\Helper\ServerUrl does not take into account when the request is coming from a proxy server. Here is that patch.

<pre class="highlight">
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && !empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
            if (strpos($host, ',')) {
                // See Symfony ticket #3842 (<a href=""></a>)
                $hosts = explode(',', $host);
                $host = array_pop($hosts);
        } elseif (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) {


Posted by John Kelly (postalservice14) on 2012-08-31T15:04:30.000+0000

Pull request sent:

Posted by Ralph Schindler (ralph) on 2012-10-08T20:14:46.000+0000

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit:

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.