From e08ffc472c136c36308f14b67b442f35f6516583 Mon Sep 17 00:00:00 2001 From: Augustin Borsu Date: Wed, 21 Oct 2015 05:29:33 +0200 Subject: [PATCH] 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 --- .../web-servers/apache-httpd/owncloud.nix | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix index a5e539bc9ba..b3f47cddecc 100644 --- a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix +++ b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix @@ -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 + ''} ${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 = ''