http://kiros33.blog.me/220342620620
Revision History
2015/04/27 10:04:09 - 최초 작성
Link
Reference Page
아파치로 WebDAV 설정하는 방법, 우분투 12.04
오늘부로 갤럭시 S4 구매할 때 받았던 드랍박스 48GB 상품이 만료되었습니다. 꺼이 꺼이... 돈주고 쓰긴 애매하고 약 22GB나 되는 DEVONthink 를 우짜나 고민하다가 WebDAV을 지원하길래 리눅스 기반 WebDAV을 사용하기로 마음먹었네요~
설정이 어렵지도 않고 스마트폰의 많은 앱들이 WebDAV을 지원해서 필요하면 스트리밍으로 영화도 볼 수 있겠다 싶습니다요~ (물론 공부 끝나고 ㅠ.ㅠ)
일단 원문으로 기록해둬야지~
How To Configure WebDAV Access with Apache on Ubuntu 12.04Introduction
WebDAV is a distributed web authoring implementation built into HTTP that allows you to easily share files and work collaboratively with others.
We can install this extension within a web server to allow remote read and write access to local files through a web browser. In this guide, we will be configuring WebDAV on an Ubuntu 12.04 VPS with the Apache web server.
Install Apache on the VPS
Our implementation of WebDAV will be established on Apache through the use of the WebDAV module.
First, you will need to install Apache from Ubuntu's default repositories.
You now have a fully functioning web server installed. It should be accessible already by navigating to your server's IP address in a web browser.
Enable WebDAV
Apache has built-in support for WebDAV with a few modules. We simply have to enable them to get access to their functions.
Enable the WebDAV modules with the following two commands:
We now need to restart the server to implement the changes:
WebDAV as a functionality is now enabled, but we still haven't configured it correctly yet for our server.
Create the FileSystem
We will create a directory that will house our WebDAV file content.
The default document root of the Apache server on Ubuntu is located at
/var/www . However, we will be creating an alias, which will allow us to keep our directory content elsewhere.
In this guide, we will place our WebDAV content at
/webdav/
Give the web user, which is
www-data , ownership of the new directory, so that it can serve content correctly:
Set Up Password Protection
We can create an authentication procedure for accessing the directory content by creating an htpasswd file.
We will place it outside of the content directory so that it will not be accessible to users of our system. Create a username within the command call and you will be prompted for an associated password:
sudo htpasswd -c /etc/apache2/webdav.password username
Right now, anybody can view the username and hashed password in the file. We will assign group ownership of the file to
www-data and then lock down the permissions for everyone else:
Configure Apache
Now, we will have to configure access to our content directory and tell Apache to use the WebDAV modules to serve that location. We will also have to note the authentication scheme we've created.
Edit the main virtual host configuration with root privileges:
Here, our web content is served out of
/var/www like normal. We will add some information that will allow Apache to treat content in our new directory as WebDAV material.
Below the directory listings, we will add an alias directive to tell Apache that requests for "/webdav" should be served out of the
/webdav directory we created.
We will then add options to allow authentication using the methods we established.
. . . . . . <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> Alias /webdav /webdav <Location /webdav> Options Indexes DAV On AuthType Basic AuthName "webdav" AuthUserFile /etc/apache2/webdav.password Require valid-user </Location> . . . . . .
Save and close the file.
Restart Apache with the following command:
Test the Results
You can test the results of you configuration first in a web browser, and then in a WebDAV client.
Web Browser Test
To test that your authentication is working correctly, navigate to your server's IP address or domain name using a web browser.
You should see the default Apache index.html file:
This demonstrates that the regular web functionality is working.
Now, navigate to your IP address or domain name followed by "/webdav":
your_IP_address_or_domain/webdav
You should be prompted for the username and password combination you set up earlier. Afterwards, you should see an empty directory listing:
We don't currently have any content here, but we'll be able to change that by accessing the same area with a WebDAV client.
WebDEV Client Test
There are many WebDAV clients and support for WebDAV access is baked into many popular file managers.
For simplicity's sake, we'll use an easy command-line WebDAV client called "cadaver" in this guide.
Preferably from another droplet or Linux machine, install cadaver from the default repositories:
Now, let's create a file that we'll upload to the WebDAV directory:
Next, we'll connect using the same location we used to access from the browser:
cadaver http://your_IP_address_or_domain/webdav
Authentication required for webdav on server `162.243.2.14': Username:
You must type the "http://" portion for cadaver to find your server correctly. We will need to authenticate again, and then we'll be dropped into a command-line interface.
From here, we can operate the client and host at the same time using commands that are similar to regular Linux commands.
To list the contents of the server directory, type:
The directory is empty. Let's change that uploading our test file:
We can try the list command again and see the file is now on the server:
We can make a directory and change into it by typing:
We can then create a file by typing:
We can insert whatever content we want:
When we are finished, we can type exit to close the connection:
Now, if we go back to our web browser, the changes that we've made are visible:
your_IP_address_or_domain/webdav
Turn Off Directory Listings
Although the directory listings are useful for seeing the files that WebDAV has available, it's often useful, especially if you are using this for actual web content, to turn that listing off.
If you would like the web-accessible portion to act more like a website and less like a directory listing, remove the "Options Indexes" line from the configuration file:
Alias /webdav /webdav
<Location /webdav>
Options Indexes ## Remove this line
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /etc/apache2/webdav.password
Require valid-user
</Location>
. . .
. . .
Restart Apache to use your changes:
Remember, you'll need to create regular web pages for this to function correctly, like an "index.html" file:
Save and close the file.
This page will now appear when we're navigating to the main WebDAV directory, but the edit functionality will still be enabled with clients.
Conclusion
You should now have a WebDAV directory complete with basic authentication. If your directory contains content that absolutely must be kept secure, you might want to implement an SSL solution on top of the password authentication. This, however, is outside of the scope of this article.
Many file managers and clients exist that can seamlessly access and modify WebDAV content as if it were additional local storage. WebDAV allows for a much more dynamic HTTP experience than is traditionally possible.
|
검색: Linux, 리눅스, Ubuntu, 우분투, DigitalOcean, 디지털오션, Community, 커뮤니티, Tutorial, 강좌,
댓글 없음:
댓글 쓰기