WebDAV
From DreamHost
WebDAV, or Web-based Distributed Authoring and Versioning, is an extension to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers. The World Wide Web, as conceived by Tim Berners-Lee, was always intended to be a readable and writable medium; however, as the web grew it became a largely read-only medium. WebDAV has emerged as a way to restore that functionality, although it is no longer concerned with the versioning aspect - just the distributed authoring part.
Contents |
client
Need to know how to access a WebDav directory from your local machine? Read WebDAV_How-To_Access.
server
The subsections here are ordered by need-to know: most likely a person needs to know these details.
basic setup
via DreamHost Control Panel
Do this via the Dreamhost Control Panel->Goodies->Htaccess/WebDAV. This is easy. But it appears to have killer drawbacks as one adds more users.
via your own config file (containing the DAV directive)
httpd.apache.org tells how. This is the normal method. And it could have enormous benefit over setup #via DreamHost Control Panel given the problems with that.
However, Dreamhost doesn't allow you to do this says this forum post. Why? Workarounds?
https access
If you want security that can't be broken if someone can examine you're connection link (such as tuning in to your 802.11), then you'll need to setup and use WebDAV over https - it is possible but you will need to have a unique IP address. You need to enable the SSL service on your actual domain name. You will then be able to access WebDAV via SSL. You can set up this secure service for your domain by clicking the 'edit' button located under the 'Secure Hosting' column next to your domain here: https://panel.dreamhost.com/index.cgi?tree=domain.manage
access levels which are custom and/or settings which are managed automatically
- The Dreamhost Control Panel -> Goodies-> Htaccess/WebDAV allows one to specify what users have access, and there every user then has full access to everything. And while this gets one started quick with at least the most basic security, almost immediately as one grows in users (even just one more user) this starts having increasing problems:
- it is only the coursest-grained security --and so can be very risky & destructive (compromised privacy; wrong edits, changes, delets) --most especially as one adds more users (even with just two users, one could not know and erase or delete or change something of the other);
- it doesn't allow changes automatically (as changing users, passwords, and access automatically): as thru one's PHP script, say when a user of your website wants to immediately & automatically sign-up for WebDAV access, or change the access to a folder (crucial when one starts having dozens or hundreds of users, so needs tools so they can manage much of this administrivia themselves).
- So what we'd really like to do (especially when more than one user) is to specify access levels (Access-Control-Lists) on a per-folder (or maybe even per-file) basis, and eventually (as the the user count grows) manage the users & passwords list automatically thru scripts. And on Apache (the web server Dreamhost uses), this can be done by creating/editing appropriate .htaccess & .password files, each typically placed in every folder where we want to make an exception. However:
create & edit one's own Htaccess & .password files (on Dreamhost WebDAV)
--this seems impossible -- help! As
- In this Dreamhost WebDAV, the root WebDAV folder all subfolders are set to Unix permissions rwxr-xr-x (and rwxr--r-- for every file), with the user & group being set to dhapache which seemingly no standard Dreamhost user is a member of. As a consequence, the ONLY way to create/edit any file/folder within WebDAV is thru the WebDAV protocol (ftp & sftp & sh will not work) but
- Thru WebDAV (at least on Dreamhost) it is impossible (disallowed) to create any file named ".htaccess"; it will list .htaccess (and .htpassword) (the ones already there (in the WebDAV root)) but the .htaccess which is there has permissions r-------- so it is impossible for anyone (but user dhapache) to access.
Anyone know how to fix?? Please write solutions here:
- Possibly use Subversion instead of WebDAV. As
- though more complex to setup,
- Dreamhost Subversion can have directory level access-control (though still a security hole as DH doesn't (yet?) provide support to reset the chmod after a custom change)
- Subversion can provide WebDAV which also has basic auto-versioning
- Any drawbacks?
- Use #basic setup #via your own config file (containing the DAV directive) instead. But how?
access the source of files normally pre-processed by the web server
One problem with WebDAV is that it does not allow you to edit the source of server processed files, including PHP, shtml, Perl, etc. This is because it uses the same command to "GET" the file as your web browser. The webserver has no way of knowing to not process the php file and give you the output instead of the source code. Adding this line to your .htaccess file will disable all processing:
SetHandler default-handler
Meaning .php files will show their source, including any passwords you have coded in. You will need to get support to add this line, as well as change the permissions to allow you to edit the file. Any changes made to this file will be overwritten if you make any changes in the panel to your htaccess/webdav options.
applying WebDAV to an entire domain, not just to one of its folder
This is mostly aesthetic (why it's listed last), but still sometimes desirable. As setup #via DreamHost Control Panel won't currently allow you to apply WebDAV to an entire domain. But, using the magic of Apache's rewrite module, you can make it seem like you are.
A note of caution
WebDAV uses it's own .htaccess and .htpassword file which are controlled by the WebDAV interface and may not always be visible. This may cause "abnormal" behavior in certain instances, such as creating a WebDAV directory off of your domain's root directory (e.g. http://example.com/webdav/). There is at least one incident where doing this caused processing of the pre-existing .htaccess file to silently fail resulting in no page display. It is suggested that if you're creating a WebDAV directory, you ensure that the target WebDAV (as well as it's parent) are reasonably isolated from your main site.
Step 1
Use the WebDAV goodies panel to setup a directory with WebDAV enabled. For the rest of this guide it will be assumed that the directory is called "site".
Step 2
If you already have any data or directories you want to be part of the new WebDAV site then connect to your new WebDAV share and upload them there. The URL of your WebDAV share should be something like http://yourURL/site/. Don't worry about modifying the links within your pages. The magic we will do in the next step means they will still work exactly the same way they currently do.
Step 3
Now we have to use a .htaccess file to rewrite requests to http://yourURL to use the data stored in http://yourURL/site/ (afterwards visitors wont even know it's happening). In the main folder for your domain you should put a file called ".htaccess". Make sure you include the period at the start. Put the following text into the file:
RewriteEngine on
RewriteCond %{REQUEST_URI} !site/
RewriteRule ^(.*)$ /site/$1
The first line turns on rewriting. The second line tells the webserver not to rewrite http://yourURL/site/ and the third line line tell the webserver to rewrite all requests to http://yourURL/ to use the data from http://yourURL/site/. If you have directories that you don't want to be under WebDAV control then you should add additions RewriteCond lines like the one for "sites". For example if you don't want the directory "scripts" to be rewritten you would add the line:
RewriteCond %{REQUEST_URI} !scripts/
Conclusion
That's it! When you surf to http://yourURL/ you should actually be sent the data from http://yourURL/site/ but your URLs will look exactly the same as they did before.

