I have two directories in each of my users' home folders: .html-data
and .cgi-bin
. The first one contains static (.html) files, the second one contains files for dynamic document generation.
Each user should be able to publish the content of the .html-data
folder on http://myhost.com/~<username>/
and the content of the .cgi-bin
folder on http://myhost.com/~<username>/cgi-bin/
. The scripts for dynamic content creation should be executed as the user who provides them (e.g. ~steve/cgi-bin/test.cgi
should be executed as user steve).
For that I configured the following configuration for the userdir module of Apache 2.4:
UserDir .html-data
UserDir disabled root
<Directory "/home/*/.html-data">
RewriteEngine On
RewriteBase /~username/
RewriteRule "^/cgi-bin/(.*)" "../../.cgi-bin/$1"
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
<Directory "/home/*/.cgi-bin">
Options ExecCGI
SetHandler cgi-script
Satisfy any
</Directory>
However, this does not work. The RewriteRule seems wrong. How can I refer to the user's .cgi-bin
directory?
This is the error log:
[Thu Aug 04 20:14:17 2016] [trace3] mod_rewrite.c(477): [client 10.0.2.2:44058] 10.0.2.2 - - [myhost.com/sid#19f4a48][rid#1a639b0/initial] [perdir /home/*/.html-data/] add path info postfix: /home/steve/.html-data/cgi-bin -> /home/steve/.html-data/cgi-bin/hello.cgi
[Thu Aug 04 20:14:17 2016] [trace3] mod_rewrite.c(477): [client 10.0.2.2:44058] 10.0.2.2 - - [myhost.com/sid#19f4a48][rid#1a639b0/initial] [perdir /home/*/.html-data/] applying pattern '^/cgi-bin/(.*)' to uri '/home/steve/.html-data/cgi-bin/hello.cgi'
[Thu Aug 04 20:14:17 2016] [trace1] mod_rewrite.c(477): [client 10.0.2.2:44058] 10.0.2.2 - - [myhost.com/sid#19f4a48][rid#1a639b0/initial] [perdir /home/*/.html-data/] pass through /home/steve/.html-data/cgi-bin