HY,
我一直在寻找相同的东西,最后我使用apache2收集了一个解决方案。我使用npm webdav-server尝试了节点解决方案,结果发现并不是所有的工作都和使用apache模块一样好。然后,我尝试了一个基于jsDAV的npm dav服务器,它可以做得更好,并且可以作为解决方案,但是由于不得不处理糟糕的3g连接,我更喜欢apache并发现了多个实例脚本。
所以我在这里分享我的经验。
http://helpcenter.epages.com/Doc/doc/apache2/README.multiple-instances
我为每个webdav用户运行一个实例...伸缩性不是很好,但是要在一个小的团队中工作就足够了。
用您的用户替换myUser。
在Ubuntu 14.04上
sh /usr/share/doc/apache2/examples/setup-instance myUser
所以我以/ etc / apache2-myUser / envars中定义的用户myUser运行apache进程
export APACHE_RUN_USER=myUser
export APACHE_RUN_GROUP=myUser
编辑ports.conf
# If you proxy with nginx as I did better to limit to local interface
listen localhost:8080
# listen 8080
我无法在ubuntu 14.04上获得PAM身份验证以正常工作,因此需要欺骗基本身份验证,然后再使用Nginx将其包装在https中
htpasswd -c /etc/apache2/htpasswd myUser
然后/etc/apache2-myUser/sites-available/000-default.conf
<VirtualHost *:8080>
DocumentRoot /var/www/html
Alias /${APACHE_RUN_USER} /home/${APACHE_RUN_USER}
<Directory /home/${APACHE_RUN_USER}>
Require all granted
Options +Indexes
</Directory>
<Location /${APACHE_RUN_USER}>
DAV On
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /etc/apache2/htpasswd
Require valid-user
</Location>
DavLockDB /home/${APACHE_RUN_USER}/.DavLock
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
然后nginx代理有一个技巧,标题传递目的地图标文件夹可以让webdav在浏览器上很好地降级
server {
listen 443 ssl http2;
server_name exemple.com;
location ~ ^/(myUser|icons)/ {
proxy_pass http://dav-myUser;
# auth_basic "Restricted Content";
# auth_basic_user_file /etc/nginx/htpasswd;
# proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
port_in_redirect off;
# to avoid 502 Bad Gateway:
# http://vanderwijk.info/Members/ivo/articles/ComplexSVNSetupFix
set $destination $http_destination;
if ($destination ~* ^https(.+)$) {
set $destination http$1;
}
proxy_set_header Destination $destination;
proxy_read_timeout 300;
proxy_connect_timeout 5;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
# Remove the Connection header if the client sends it,
# it could be "close" to close a keepalive connection
proxy_set_header Connection "";
}
ssl on;
ssl_certificate /etc/letsencrypt/live/exemple.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/exemple.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
}
没有义务使用nginx作为代理,apache可以很好地执行https,但是当我碰到代理Destination问题时,我觉得值得一提。