-
Notifications
You must be signed in to change notification settings - Fork 2
/
ConfiguringWebDAVContribWithApache.txt
191 lines (162 loc) · 7.74 KB
/
ConfiguringWebDAVContribWithApache.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
%META:TOPICINFO{author="ProjectContributor" comment="autosave" date="1356278806" format="1.1" version="1"}%
---+ Configuring WebDAVContrib with Apache2 and mod_perl
<!--
* Set CONFHOST = %URLPARAM{"confhosth" default="%HTTP_HOST%"}%
* Set CONFPATH = %URLPARAM{"confpath" default="/var/www/wiki"}%
* Set CONFURL = %URLPARAM{"confurl" default="/dav"}%
-->
If your site is already running on Apache2 with mod_perl2, then the simplest
way to configure WebDAV is to use the same Apache server. If you are using
=mod_fcgid=, see ConfiguringWebDAVContribWithFCGI.
---++ Configuration Wizard
Configuring <nop>%TOPIC% for use with Foswiki and Apache2 mod_perl2.
---+++ Step 1: basic settings
<div class="foswikiFormSteps">
<form name="config" action="%SCRIPTURLPATH{view}%/%WEB%/%TOPIC%#InstaInstr">
<div class="foswikiFormStep">
<h3>Foswiki server host:</h3>
<input class="foswikiInputField" type="text" name="confhost" size="80" value="%CONFHOST%" />
<div class="foswikiFormDescription">Enter the server host name.</div>
</div>
<div class="foswikiFormStep">
<h3>URL path:</h3>
<input class="foswikiInputField" type="text" name="confurl" size="80" value="%CONFURL%" />
<div class="foswikiFormDescription">Enter the required URL path to the DAV resources.</div>
</div>
<div class="foswikiFormStep">
<h3>Installation directory:</h3>
<input class="foswikiInputField" type="text" name="confpath" size="80" value="%CONFPATH%" />
<div class="foswikiFormDescription">Enter the directory path to your Foswiki installation on the server.</div>
</div>
<div class="foswikiFormStep foswikiFormLast foswikiFormButtons">
<input class="foswikiSubmit" type="submit" value="Submit" />
<div class="foswikiFormDescription">
Clicking on Submit will rewrite the installation
instructions below.
</div>
</div>
</form>
</div>
#InstaInstr
---+++ Step 2: mod_perl configuration
Create the file =%CONFPATH%/tools/WebDAVContrib_mod_perl_startup.pl= with the
following content:
<pre>
use ModPerl::RegistryLoader;
use lib '%CONFPATH%/bin';
do 'setlib.cfg';
1;
</pre>
This tells !WebDAVContrib where you want to run Foswiki from.
---+++ Step 3: Apache configuration
Add the following to your Apache configuration (must be included into the
base configuration; will *not* work in =.htaccess=)
This exposes the =%CONFURL%= path on your server. You can change this location
to whatever you want, but make sure the =FoswikiLocation= matches it.
<pre>
PerlRequire "%CONFPATH%/tools/WebDAVContrib_mod_perl_startup.pl"
PerlLoadModule Apache::FoswikiDAVHandler
<Location "%CONFURL%">
SetHandler perl-script
FoswikiLocation "%CONFURL%"
FoswikiFilesysHandler Filesys::Virtual::Foswiki
PerlHandler Apache::FoswikiDAVHandler
</Location>
</pre>
This will configure DAV *without authentication*, so all transactions will use
the "guest" login. See "Configuring authentication" below for information
on configuring web server authentication.
Restart your apache server.
The path http://%CONFHOST%%CONFURL% should now show you all your root
webs, when viewed from a DAV-enabled client.
---+++ Step 4: Testing
The best way to verify your server is working is to use a simple, reliable
!WebDAV client program such as =cadaver= (available for most platforms
- you can get a Windows version from
http://www.phtagr.org/2009/04/01/cadaver-for-windows/ **).
Run =cadaver= and open the DAV folder on the server:
<pre>
dav:!> open http://%CONFHOST%%CONFURL%
dav:%CONFURL%/> ls
Listing collection `%CONFURL%/': succeeded.
Coll: Main 4096 Mar 25 12:42
Coll: Sandbox 4096 Apr 6 08:19
Coll: System 20480 Apr 7 10:32
...
dav:%CONFURL%/> cd Sandbox
dav:%CONFURL%/> put packages.txt LoremIpsum.txt
Progress: [===================>] 100.0% of 320 bytes succeeded
dav:%CONFURL%/> cat LoremIpsum.txt
Displaying `/dav/Sandbox/LoremIpsum.txt':
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum....
dav:%CONFURL%/> cd LoremIpsum_files
dav:%CONFURL%/> put muspimerol.gif
Progress: [===================>] 100.0% of 2800 bytes succeeded
dav:%CONFURL%/> ls
Listing collection `/%CONFURL%/Sandbox/LoremIpsum_files/': succeeded.
muspimerol.gif 2800 Apr 12 14:38
</pre>
If cadaver reports any errors, check your apache error log on the server.
You can verify that the !LoremIpsum topic has been created by going to %SCRIPTURL{view}%/Sandbox/LoremIpsum.
=user="BaseUserMapping_666"= shows that the creation of the !LoremIpsum topic and the subsequent uploading of the =muspimerol.gif= attachment was done using the !WikiGuest user. If you try to do the same in the System directory, you will get a failure response:
<pre>
dav:!> open http://%CONFHOST%%CONFURL%
dav:%CONFURL%/> cd Sandbox
dav:%CONFURL%/> put packages.txt LoremIpsum.txt
Uploading packages.txt to `/dav/System/LoremIpsum.txt':
Progress: [=============================>] 100.0% of 320 bytes failed:
401 Authorization Required
</pre>
(At this point attempting to access the !WebFolder using Windows XP service pack 2 allows you to browse the folders, but opening any files will fail)
---+++ Step 5: Configuring authentication
If you configured your server as described above, it will be configured *without* authentication. That means that all transactions will happen as the "guest" user. In most cases you will want to require a login by the client, so that the user can be identified.
To configure authentication you simply protect the folder using
an _Apache_ authentication method of choice. !WebDAVContrib will automatically
log in to Foswiki using the username (or Wiki Name) that was used to log in
to Apache.
For example, you could use Basic Authentication to protect the DAV folder,
using the password file used by the default Foswiki setup:
<pre>
PerlRequire "%CONFPATH%/tools/WebDAVContrib_mod_perl_startup.pl"
PerlLoadModule Apache::FoswikiDAVHandler
<Location "%CONFURL%">
SetHandler perl-script
FoswikiLocation "%CONFURL%"
FoswikiFilesysHandler Filesys::Virtual::Foswiki
FoswikiDebug 0
PerlHandler Apache::FoswikiDAVHandler
%RED%AuthName "Foswiki"
AuthUserFile %CONFPATH%/data/.htpasswd
AuthType Basic
<LimitExcept OPTIONS>
require valid-user
</LimitExcept>%ENDCOLOR%
</Location>
</pre>
Restart the web server after any change to the Apache configuration.
(Note that OPTIONS requests are excluded from authentication because of a bug in Windows WebDAV, which doesn't send authentication headers with OPTIONS requests. This is not a significant security risk, as OPTIONS only tells the client what the server's capabilities are.)
<pre>
C:\Documents and Settings\Administrator\Desktop\cadaver>cadaver.bat
dav:!> open http://%CONFHOST%%CONFURL%
Authentication required for Foswiki on server `%CONFHOST%':
Username: BillGates
Password:
dav:%CONFURL%/> ls
Listing collection `/%CONFURL%/': succeeded.
Coll: Main 4096 Feb 24 07:14
Coll: Sandbox 4096 Apr 10 00:51
Coll: System 24576 Apr 9 09:01
...
</pre>
Note that Basic Authentication is much more secure if used over
SSL (with https: URLs).
---++ Debugging
If you are having problems with !WebDAV you can enable tracing in the Apache
handler and the file system interface using the =FoswikiDebug= Apache
directive. See WebDAVContrib#Debugging for more information.