Dufs一个独特的文件服务器,支持静态文件、访问控制、上传、搜索和webdav功能。 dufs server dufs特性

安装dufs

官方下载地址 https://github.com/sigoden/dufs/releases 天朝地址

根据系统类型下载文件,解压后只有一个dufs单文件

tar zxf dufs-v0.41.0-x86_64-unknown-linux-musl.tar.gz
mv dufs /usr/local/bin/
chmod +x /usr/local/bin/dufs

使用dufs

dufs命令行参数

dufs --help
Dufs is a distinctive utility file server - https://github.com/sigoden/dufs

Usage: dufs [OPTIONS] [serve-path]

Arguments:
  [serve-path]  Specific path to serve [default: .]

Options:
  -c, --config <file>        Specify configuration file
  -b, --bind <addrs>         Specify bind address or unix socket
  -p, --port <port>          Specify port to listen on [default: 5000]
      --path-prefix <path>   Specify a path prefix
      --hidden <value>       Hide paths from directory listings, e.g. tmp,*.log,*.lock
  -a, --auth <rules>         Add auth roles, e.g. user:pass@/dir1:rw,/dir2
  -A, --allow-all            Allow all operations
      --allow-upload         Allow upload files/folders
      --allow-delete         Allow delete files/folders
      --allow-search         Allow search files/folders
      --allow-symlink        Allow symlink to files/folders outside root directory
      --allow-archive        Allow zip archive generation
      --enable-cors          Enable CORS, sets `Access-Control-Allow-Origin: *`
      --render-index         Serve index.html when requesting a directory, returns 404 if not
                             found index.html
      --render-try-index     Serve index.html when requesting a directory, returns directory
                             listing if not found index.html
      --render-spa           Serve SPA(Single Page Application)
      --assets <path>        Set the path to the assets directory for overriding the built-in
                             assets
      --log-format <format>  Customize http log format
      --log-file <file>      Specify the file to save logs to, other than stdout/stderr
      --compress <level>     Set zip compress level [default: low] [possible values: none, low,
                             medium, high]
      --completions <shell>  Print shell completion script for <shell> [possible values: bash,
                             elvish, fish, powershell, zsh]
      --tls-cert <path>      Path to an SSL/TLS certificate to serve with HTTPS
      --tls-key <path>       Path to the SSL/TLS certificate's private key
  -h, --help                 Print help
  -V, --version              Print version

使用实例

当前目录只读模式运行

dufs

dufs

允许所有操作权限,如上传、删除、搜索、新建、编辑等。

dufs -A

dufs -A

仅允许上传操作

dufs --allow-upload

dufs –allow-upload 指定特定目录

dufs ~/.ssh

dufs ~/.ssh

指定单文件服务,浏览即下载改文件

dufs blog2md.tgz

提供像 react/vue 这样的单页应用程序

dufs --render-spa

提供首页为index.html的静态文件服务

dufs --render-index

指定访问用户名、密码

dufs -a admin:123@/:rw

dufs -a admin:123@/:rw 指定ip和端口

dufs -b 127.0.0.1 -p 8080

侦听unix socket

dufs -b /tmp/dufs.socket

配置https,需要提供自定义证书文件

dufs --tls-cert my.crt --tls-key my.key