owncloud httpd-service: add urlPrefix option

This option allows user to specify a url prefix for owncloud.
By default it is set to "" and the document root will be set
to owncloud's dir.
If a prefix is set, e.g. urlPrefix = "/owncloud"
an alias will be created using that prefix to point to owncloud's
dir and owncloud will be available at http://localhost/owncloud
This commit is contained in:
Augustin Borsu 2015-10-21 05:29:33 +02:00 committed by Matej Cotman
parent a4a334bbe0
commit e08ffc472c

View file

@ -345,13 +345,12 @@ rec {
extraConfig =
''
ServerName ${config.siteName}
ServerAdmin ${config.adminAddr}
DocumentRoot ${documentRoot}
${if config.urlPrefix != "" then "Alias ${config.urlPrefix} ${pkgs.owncloud}" else ''
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
''}
<Directory ${pkgs.owncloud}>
${builtins.readFile "${pkgs.owncloud}/.htaccess"}
@ -362,12 +361,20 @@ rec {
{ name = "OC_CONFIG_PATH"; value = "${config.dataDir}/config/"; }
];
documentRoot = pkgs.owncloud;
documentRoot = if config.urlPrefix == "" then pkgs.owncloud else null;
enablePHP = true;
options = {
urlPrefix = mkOption {
default = "";
example = "/owncloud";
description = ''
The URL prefix under which the owncloud service appears.
'';
};
id = mkOption {
default = "main";
description = ''