搭建webdav

搭建自己的webdav

  1. 使用docker-compose安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '3'
services:
webdav:
image: bytemark/webdav
container_name: webdav
restart: always
ports:
- "81:80"
environment:
AUTH_TYPE: Digest
USERNAME: username
PASSWORD: xxxxxxx
volumes:
- /home/<username>/webdav/dav:/var/lib/dav
#- /home/<username>/webdav/apache2_conf/httpd.conf:/usr/local/apache2/conf/httpd.conf
  1. 使用nginx反代
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server {
listen 80;
server_name dav.xx.com;
location / {
proxy_pass http://127.0.0.1:81;
proxy_set_header Host $host;
proxy_set_header remote_addr $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
# 此方法可能不适合域名反代
add_header X-Cache $upstream_cache_status;
add_header Cache-Control no-cache;
}
#禁止爬虫,if语句必须放在server或者location范围内,不能放在http范围内。
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot" ) { return 403; }
access_log /www/wwwlogs/dav.xx.com.log; #日志可以不写
error_log /www/wwwlogs/dav.xx.com.error.log;
}

应用里显示正常,网页现在显示的是乱码,看着很不舒服

需要修改‘httpd.conf’的配置,首先需要将文件挂载到本地,要不然重启容器后会消失

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
docker exec -it webdav bash
su root
cp /usr/local/apache2/conf/httpd.conf /var/lib/dav/
exit
exit
mv /home/<username>/webdav/dav/httpd.conf /home/<username>/webdav/apache2_conf/httpd.conf

vim httpd.conf
#加在ServerRoot下面,大概在32行
AddDefaultCharset utf-8
IndexOptions +Charset=UTF-8
AddCharset UTF-8 .utf8

#取消docker-compose.yaml注释
docker-compose down && docker-compose up -d

刷新网页就变成正常字体了


搭建webdav
https://shyi.org/posts/35575/
作者
Shyi
发布于
2022年9月9日
更新于
2024年9月7日
许可协议