--- a/configs/apache.conf Tue Dec 29 23:39:37 2015 +0100
+++ b/configs/apache.conf Wed Dec 30 23:18:35 2015 +0100
@@ -1,39 +1,45 @@
-# -> /etc/apache2/conf.d
+# This file should be placed as
+# -> /etc/apache2/conf-available/once.conf
+# and then you may use `a2enconf once`
+<Macro ONCE $location $var $lib>
+ SetEnv ONCE_VAR $var
+ SetEnv ONCE_LIB $lib
-# The directory where the files are stored,
-# it needs to be writable by the web server user (wwwrun, www-data,
-# who ever)
-# SentEnv may go into the <Directory>...</Directory>
-SetEnv ONCE_VAR /var/lib/once/
-
-
-# Action may go into <Location>...</Location>
-Action once-handler /once-handler/once.cgi virtual
+ # The directory where the files are stored.
+ # This directory needs to be r/w by the web server user
+ # (wwwrun, www-data, who ever), but it must not be
+ # accessible via HTTP(s)
+ <Directory $var>
+ Require all denied
+ </Directory>
-# Order of location blocks matters!
-<Location "/once">
- SetHandler once-handler
-</Location>
-<Location "/once/public">
- SetHandler none
-</Location>
+ Action once-handler /once-handler/once.cgi virtual
+ ScriptAlias /once-handler/ $lib/
+ Alias $location/public $lib/public
-#<Location "/once/d">
-# SetHandler once-download-handler
-# Action once-download-handler /once-handler/download.pl virtual
-#</Location>
+ # Order of location blocks matters!
+ # We handle requests to our script, with the exception (see below)
+ # for …/public/… requests. These should be answered from a simple
+ # static directory for style sheets and similiar
+ <Location "$location">
+ SetHandler once-handler
+ </Location>
+ <Location "$location/public">
+ SetHandler none
+ </Location>
-Alias /once/public /usr/local/lib/once/public
-<Directory "/usr/local/lib/once/public">
+ <Directory "$lib/public">
Require all granted
Allow from all
-</Directory>
-
+ </Directory>
-ScriptAlias /once-handler/ /usr/local/lib/once/
-<Directory "/usr/local/lib/once">
+ <Directory "$lib">
Require all granted
Allow from all
Options ExecCGI FollowSymlinks
-</Directory>
+ </Directory>
+</Macro>
+
+Use ONCE /once /var/lib/once /usr/local/lib/once
+UndefMacro ONCE