ubuntu通过nginx搭建webdav服务器

1、webdav

  WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通信协议。它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法,使应用程序可对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制

——来自百度百科https://baike.baidu.com/item/WebDAV

2、安装nginx-full

通过nginx搭建webdav服务需要安装http_dav_module模块。nginx-full版本中直接包含了http_dav_module模块。

安装命令:

sudo install nginx-full

3、编辑webdav配置文件

3.1新建webdav.conf配置文件

sudo vim /etc/nginx/conf.d/webdav.conf

3.2写入配置内容

查看代码
 server {
    listen 8081;
    listen [::]:8081;

    server_name localhost;

    # 认证方式
    auth_basic              realm_name;
    # 存放认证用户名、密码文件(确认有对应权限)
    auth_basic_user_file    /etc/webdav/.credentials.list;
    # webdav服务访问的根目录
    root /home/username/;

    # dav allowed method
    dav_methods     PUT DELETE MKCOL COPY MOVE;
    # Allow current scope perform specified DAV method
    dav_ext_methods PROPFIND OPTIONS;

    # In this folder, newly created folder or file is to have specified permission. If none is given, default is user:rw. If all or group permission is specified, user could be skipped
    dav_access      user:rw group:rw all:r;

    # Temporary folder
    client_body_temp_path   /tmp/webdav;

    # MAX size of uploaded file, 0 mean unlimited
    client_max_body_size    0;

    # Allow autocreate folder here if necessary
    create_full_put_path    on;
}

3.3测试配置文件

sudo nginx -t

4、创建用户登录验证信息(用户名-密码)

sudo echo -n 'username:' | tee -a /etc/webdav/.credentials.list
sudo openssl passwd -apr1 | tee -a /etc/webdav/.credentials.list

5、重启nginx服务

sudo systemctl restart nginx

查看nginx状态

sudo systemctl status nginx

6、nginx重启成功后即可访问webdav服务

http://主机IP:8081

输入配置的用户名和密码验证成功后便可正常进行操作

7、扩展

可以搭配frp等内网穿透工具将本地webdav服务暴露,这样就可以将本地主机当做网盘来使用。

手机客户端可使用ES文件浏览器,使用效果良好。

玩法挺多,慢慢探究。 

posted @   tros  阅读(4567)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示