Skip to content
Snippets Groups Projects
Commit 805dce77 authored by mathieugrimault's avatar mathieugrimault Committed by Robert Lange
Browse files

Add support for running VuFind behind a reverse proxy (#1429)

parent ba1e9d3b
No related merge requests found
......@@ -24,6 +24,9 @@ autoConfigure = true
; Base URL is normally auto-detected, but this setting is used when autodetection is
; not possible (i.e. during sitemap generation at the command line).
url = http://library.myuniversity.edu/vufind
; Set to true if VuFind is behind a reverse proxy (typically Apache with mod_proxy),
; make sure your reverse proxy sets the necessary headers.
;reverse_proxy = true
email = support@myuniversity.edu
title = "Library Catalog"
; This is the default theme for non-mobile devices (or all devices if mobile_theme
......
<?php
/**
* ServerUrl helper factory. This uses the core Zend helper but configures it
* according to VuFind settings.
*
* PHP version 7
*
* Copyright (C) Villanova University 2019.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace VuFind\View\Helper\Root;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
/**
* ServerUrl helper factory.
*
* @category VuFind
* @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class ServerUrlFactory implements FactoryInterface
{
/**
* Create an object
*
* @param ContainerInterface $container Service manager
* @param string $requestedName Service being created
* @param null|array $options Extra options (optional)
*
* @return object
*
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName,
array $options = null
) {
if (!empty($options)) {
throw new \Exception('Unexpected options sent to factory.');
}
$cfg = $container->get(\VuFind\Config\PluginManager::class)->get('config');
$helper = new $requestedName();
if ($cfg->Site->reverse_proxy ?? false) {
$helper->setUseProxy(true);
}
return $helper;
}
}
......@@ -65,6 +65,7 @@ return [
'VuFind\View\Helper\Root\Url' => 'VuFind\View\Helper\Root\UrlFactory',
'VuFind\View\Helper\Root\UserList' => 'VuFind\View\Helper\Root\UserListFactory',
'VuFind\View\Helper\Root\UserTags' => 'VuFind\View\Helper\Root\UserTagsFactory',
'Zend\View\Helper\ServerUrl' => 'VuFind\View\Helper\Root\ServerUrlFactory',
],
'aliases' => [
'accountCapabilities' => 'VuFind\View\Helper\Root\AccountCapabilities',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment