webdav

最后发布时间:2023-09-03 23:19:38 浏览量:

nginx使用webdav

sudo apt install -y nginx-full
.
├── conf.d
├── fastcgi.conf
├── fastcgi_params
├── koi-utf
├── koi-win
├── mime.types
├── modules-available
├── modules-enabled
│   ├── 50-mod-http-auth-pam.conf -> /usr/share/nginx/modules-available/mod-http-auth-pam.conf
│   ├── 50-mod-http-dav-ext.conf -> /usr/share/nginx/modules-available/mod-http-dav-ext.conf
|
├── nginx.conf
├── proxy_params
├── scgi_params
├── sites-available
│   └── default
├── snippets
│   ├── fastcgi-php.conf
│   └── snakeoil.conf
├── uwsgi_params
├── webdav.conf
└── win-utf


cat /etc/nginx/nginx.conf

pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
	# multi_accept on;
}

http {
	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;
	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##
	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##
	gzip on;
	include /etc/nginx/conf.d/*.conf;
}

cat /etc/nginx/conf.d/cms.conf

server {
    listen 80;
    server_name www.bioinfo.online bioinfo.online 47.241.101.253;
    #root /root/cms/html;

    location / {
    proxy_pass http://localhost:8080;
    }

    location /vv {

        proxy_pass http://localhost:8888;
    }

    location /webdav {
        root /home/dav;
        # alias /data/dav;
        autoindex on;

        dav_methods PUT DELETE MKCOL COPY MOVE;
        # 需要 nginx-dav-ext-module 才有下面的选项
        dav_ext_methods PROPFIND OPTIONS;
        create_full_put_path on;
        dav_access user:rw group:r all:r;
        auth_basic "Authorized Users Only";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

htpasswd -c /etc/nginx/.htpasswd ubuntu
sudo mkdir -p /home/dav
sudo chown -R www-data:www-data /home/dav
curl -X PUT -u user:passwd 'http://localhost/a' --data-binary @~/Downloads/xxx.txt

查看错误

tail -f /var/log/nginx/error.lo

Apache使用webdav

sudo apt install -y apache2
root@www:~# apt -y install apache2-utils
root@www:~# mkdir /home/webdav
root@www:~# chown www-data. /home/webdav
root@www:~# chmod 770 /home/webdav
root@www:~# vi /etc/apache2/sites-available/webdav.conf
# create new
Alias /webdav /home/webdav
<Location /webdav>
    DAV On
    SSLRequireSSL
    Options None
    AuthType Basic
    AuthName WebDAV
    AuthUserFile /etc/apache2/.htpasswd
    <RequireAny>
        Require method GET POST OPTIONS
        Require valid-user
    </RequireAny>
</Location>

# add a user : create a new file with [-c]
root@www:~# htpasswd -c /etc/apache2/.htpasswd ubuntu
New password:     # set password
Re-type new password:
Adding password for user ubuntu
root@www:~# a2enmod dav*
Enabling module dav.
Considering dependency dav for dav_fs:
Module dav already enabled
Enabling module dav_fs.
Enabling module dav_lock.
To activate the new configuration, you need to run:
  systemctl restart apache2

root@www:~# a2ensite webdav
Enabling site webdav.
To activate the new configuration, you need to run:
  systemctl reload apache2

root@www:~# systemctl restart apache2

windows连接wendav

net use Z: \\server\share /user:username password

请将 `\\server\share` 替换为您的 WebDAV 服务器地址,`username` 替换为您的用户名,`password` 替换为您的密码。

linux 连接wendav

davs://yourportal.onlyoffice.com/webdav

spring boot 实现webdav

https://hfakhraei.github.io/Create-WebDav-Server-with-Spring-Boot-and-Milton

参考