1. 아파치 모듈 활성화
a2enmod dav
a2enmod dav_fs
a2enmod autoindex
a2enmod auth_digest
a2enmod auth_basic
a2enmod alias
a2enmod access_compat
a2enmod ssl
a2enmod autoindex
systemctl restart apache2
2. webdav 인증 사용자 추가
htpasswd -c /etc/apache2/webdav.passwd davuser
New password: password1
htpasswd /etc/apache2/webdav.passwd davadmin
New password: password2
chmod 640 /etc/apache2/webdav.passwd
chown root:www-data /etc/apache2/webdav.passwd
3. SSL 인증서 생성 (한 줄씩 실행한다)
rm -rf /etc/apache2/ssl/*
ntpdate -v kr.pool.ntp.org
head -c 32 < /dev/random > ~/.rnd
openssl genrsa -des3 -out ssl-cert-apache2.key 2048
openssl req -new -days 18250 -key ssl-cert-apache2.key -out ssl-cert-apache2.csr -subj "/C=KR/ST=Seoul/L=Guro-gu/O=My Office/OU=Web Server/CN=apache2"
cp -fv ssl-cert-apache2.key ssl-cert-apache2.key.orig
openssl rsa -in ssl-cert-apache2.key.orig -out ssl-cert-apache2.key
openssl x509 -req -days 18250 -in ssl-cert-apache2.csr -signkey ssl-cert-apache2.key -out ssl-cert-apache2.crt
mkdir -p /etc/apache2/ssl/private
mkdir -p /etc/apache2/ssl/certs
mv -fv ssl-cert-apache2.key* /etc/apache2/ssl/private/
mv -fv ssl-cert-apache2.crt /etc/apache2/ssl/certs/
mv -fv ssl-cert-apache2.csr /etc/apache2/ssl/certs/
chown -R www-data:www-data /etc/apache2/ssl
4. vi /etc/apache2/sites-available/webdav.conf
DavLockDB "/etc/apache2/DavLock"
Alias "/dav" "/mnt/storage"
SSLEngine on
SSLCertificateFile "/etc/apache2/ssl/certs/ssl-cert-apache2.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/private/ssl-cert-apache2.key"
<Location "/dav">
Dav On
SSLRequireSSL
AuthType Basic
AuthName "webdav"
AuthUserFile "/etc/apache2/webdav.passwd"
AuthDigestProvider file
<Limit GET OPTIONS PROPFIND>
Require valid-user
</Limit>
<LimitExcept GET OPTIONS PROPFIND>
Require user davadmin
</LimitExcept>
</Location>
<Directory "/mnt/storage">
Dav On
Order Allow,Deny
Allow from all
AllowOverride None
IndexOptions FancyIndexing
IndexOptions FoldersFirst
IndexOptions NameWidth=*
IndexOrderDefault Ascending Name
Options Indexes
AddDefaultCharset utf-8
IndexOptions Charset=utf-8
</Directory>
5. 정리 작업 후 webdav 사이트 활성화
touch /etc/apache2/DavLock
chown www-data:www-data /etc/apache2/DavLock
a2ensite webdav
systemctl restart apache2
6. 테스트
https://10.10.10.145/dav