Skip to content

Add support for using single Roundcube installation from multiple httpd servers on one host.#73

Closed
blacklion wants to merge 1 commit into
roundcube:masterfrom
blacklion:master
Closed

Add support for using single Roundcube installation from multiple httpd servers on one host.#73
blacklion wants to merge 1 commit into
roundcube:masterfrom
blacklion:master

Conversation

@blacklion

Copy link
Copy Markdown

I have shared hosting server with such config:

Each user has its own copy of Apache, running from this user's account (and serving on localhost:40${userid}). Single nginx used to multiplex all requests according to hostnames to multiple Apache servers. So, no scripts or PHP code are running from "root" or "www" account.

Some users want to use Roundcube on their hosts, and want ability to configure it without my help (and without editing system configs, which they could not do anyway).

I, as host admin, want to have only one copy of Roundcube sources on my system, under control of package manager, as it allows me to upgrade software and track vulnerabilities. I don't want to monitor each user server for installed Roundcube and force them to upgrade.

Here is problem with current Roundcube: it allows to have per-host configuration files with 'include_host_config', but all of them should live in on directory, which should not be writable by users. Also, users could add server aliases, and when new server alias is added, it should be added to main Roundcube config too (to load appropriate host config). Or every server alias should have its own host config, in non-user-writable directory. It is ugly.

With this commit I've added new configuration parameter: 'use_document_root'

If this parameter is set, it is used as suffix to $_SERVER['DOCUMENT_ROOT'], and resulting path is used as new root for configuration, temporary and log directories. main.inc.php is reloaded from new config directory, and db.inc.php and host-dependent config is looked up in this new path, too. mimetypes.php, plugins and themes are still looked up in install path (maybe, it is good idea, to add ability to use per-user plugins and themes, too, but it is not included in this commit, as Roundcube should be able to find plugins and themes in TWO places, both system-wide and user-confgured, and it is much more intrusive changes).

This patch works well on my own server like this:

(1) Roundcube installed with packet manager to /usr/local/www/roundcube. No server uses/serves this path directly.
(2) "/usr/local/www/roundcube/config/main.inc.php" contains ONLY 'use_document_root' parameter, set to '../rcube'.
(3) Each user, who wants to use Roundcube on its host(s) has:
(a)
Alias /mail/ /usr/local/www/roundcube/
in its httpd.conf
(b) "rcube" directory created in home directory
(c) "/rcube/config/main.inc.php" and "/rcube/config/db.inc.php" files with settings, usually pointing to "/rcube/rcube.sqlite" as database, and with default 'log_dir' and 'temp_dir' settings, which gives "/rcube/logs" and "~/rcube/temp", nice and clean.

It works great!

I'm sure, this commit is not perfect, it could break tests and using Roundcube library in other applications, as I don;t understand this part of Roundcube completely. Feel free to use ideas from this commit for proper implementation of this feature.

 This commit adds support for using Roundcube on multiple
servers, running on same host. This support differs from
'include_host_config' in such way, that it allows
to use different db.inc.php and different main.inc.php
and different relative on different (virtual) hosts.

 If config parameter 'use_document_root' is set, all
configuration and relative paths for logs and temp files
are resolved from $_SERVER['DOCUMENT_ROOT']. It allows
to have all settings under control of web server installations,
but have Roundcube sources only once per host, under
system package manager control.
@thomascube

Copy link
Copy Markdown
Member

We'll gladly consider your pull request when refactoring the config mechanism as planned in http://trac.roundcube.net/ticket/1487311

@thomascube

Copy link
Copy Markdown
Member

Another idea: what about using environment variables from apache config to override RCUBE_CONFIG_DIR and maybe something like RCUBE_LOG_DIR and RCUBE_TEMP_DIR?

A host config (or even a .htaccess file) could then set
SetEnv RCUBE_CONFIG_DIR /home/somebody/rcube/config

That seems like a more generic approach.

@thomascube

Copy link
Copy Markdown
Member

Env variable RCUBE_CONFIG_PATH added in commit fb5f523. That should cover your use-case, too.
Although it doesn't use the DOCUMENT_ROOT variable, you can still define the paths where Roundcube looks for config file in the vhost configuration.

@thomascube

Copy link
Copy Markdown
Member

I'm closing this for now after we refactored config handling in git master.

@thomascube thomascube closed this Sep 16, 2013
@rcubetrac rcubetrac mentioned this pull request Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants