github.com/xhghs/rclone@v1.51.1-0.20200430155106-e186a28cced8/docs/content/commands/rclone_serve_webdav.md (about) 1 --- 2 date: 2020-02-01T10:26:53Z 3 title: "rclone serve webdav" 4 slug: rclone_serve_webdav 5 url: /commands/rclone_serve_webdav/ 6 --- 7 ## rclone serve webdav 8 9 Serve remote:path over webdav. 10 11 ### Synopsis 12 13 14 rclone serve webdav implements a basic webdav server to serve the 15 remote over HTTP via the webdav protocol. This can be viewed with a 16 webdav client, through a web browser, or you can make a remote of 17 type webdav to read and write it. 18 19 ### Webdav options 20 21 #### --etag-hash 22 23 This controls the ETag header. Without this flag the ETag will be 24 based on the ModTime and Size of the object. 25 26 If this flag is set to "auto" then rclone will choose the first 27 supported hash on the backend or you can use a named hash such as 28 "MD5" or "SHA-1". 29 30 Use "rclone hashsum" to see the full list. 31 32 33 ### Server options 34 35 Use --addr to specify which IP address and port the server should 36 listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all 37 IPs. By default it only listens on localhost. You can use port 38 :0 to let the OS choose an available port. 39 40 If you set --addr to listen on a public or LAN accessible IP address 41 then using Authentication is advised - see the next section for info. 42 43 --server-read-timeout and --server-write-timeout can be used to 44 control the timeouts on the server. Note that this is the total time 45 for a transfer. 46 47 --max-header-bytes controls the maximum number of bytes the server will 48 accept in the HTTP header. 49 50 --baseurl controls the URL prefix that rclone serves from. By default 51 rclone will serve from the root. If you used --baseurl "/rclone" then 52 rclone would serve from a URL starting with "/rclone/". This is 53 useful if you wish to proxy rclone serve. Rclone automatically 54 inserts leading and trailing "/" on --baseurl, so --baseurl "rclone", 55 --baseurl "/rclone" and --baseurl "/rclone/" are all treated 56 identically. 57 58 #### Authentication 59 60 By default this will serve files without needing a login. 61 62 You can either use an htpasswd file which can take lots of users, or 63 set a single username and password with the --user and --pass flags. 64 65 Use --htpasswd /path/to/htpasswd to provide an htpasswd file. This is 66 in standard apache format and supports MD5, SHA1 and BCrypt for basic 67 authentication. Bcrypt is recommended. 68 69 To create an htpasswd file: 70 71 touch htpasswd 72 htpasswd -B htpasswd user 73 htpasswd -B htpasswd anotherUser 74 75 The password file can be updated while rclone is running. 76 77 Use --realm to set the authentication realm. 78 79 #### SSL/TLS 80 81 By default this will serve over http. If you want you can serve over 82 https. You will need to supply the --cert and --key flags. If you 83 wish to do client side certificate validation then you will need to 84 supply --client-ca also. 85 86 --cert should be a either a PEM encoded certificate or a concatenation 87 of that with the CA certificate. --key should be the PEM encoded 88 private key and --client-ca should be the PEM encoded client 89 certificate authority certificate. 90 91 ### Directory Cache 92 93 Using the `--dir-cache-time` flag, you can set how long a 94 directory should be considered up to date and not refreshed from the 95 backend. Changes made locally in the mount may appear immediately or 96 invalidate the cache. However, changes done on the remote will only 97 be picked up once the cache expires. 98 99 Alternatively, you can send a `SIGHUP` signal to rclone for 100 it to flush all directory caches, regardless of how old they are. 101 Assuming only one rclone instance is running, you can reset the cache 102 like this: 103 104 kill -SIGHUP $(pidof rclone) 105 106 If you configure rclone with a [remote control](/rc) then you can use 107 rclone rc to flush the whole directory cache: 108 109 rclone rc vfs/forget 110 111 Or individual files or directories: 112 113 rclone rc vfs/forget file=path/to/file dir=path/to/dir 114 115 ### File Buffering 116 117 The `--buffer-size` flag determines the amount of memory, 118 that will be used to buffer data in advance. 119 120 Each open file descriptor will try to keep the specified amount of 121 data in memory at all times. The buffered data is bound to one file 122 descriptor and won't be shared between multiple open file descriptors 123 of the same file. 124 125 This flag is a upper limit for the used memory per file descriptor. 126 The buffer will only use memory for data that is downloaded but not 127 not yet read. If the buffer is empty, only a small amount of memory 128 will be used. 129 The maximum memory used by rclone for buffering can be up to 130 `--buffer-size * open files`. 131 132 ### File Caching 133 134 These flags control the VFS file caching options. The VFS layer is 135 used by rclone mount to make a cloud storage system work more like a 136 normal file system. 137 138 You'll need to enable VFS caching if you want, for example, to read 139 and write simultaneously to a file. See below for more details. 140 141 Note that the VFS cache works in addition to the cache backend and you 142 may find that you need one or the other or both. 143 144 --cache-dir string Directory rclone will use for caching. 145 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 146 --vfs-cache-mode string Cache mode off|minimal|writes|full (default "off") 147 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 148 --vfs-cache-max-size int Max total size of objects in the cache. (default off) 149 150 If run with `-vv` rclone will print the location of the file cache. The 151 files are stored in the user cache file area which is OS dependent but 152 can be controlled with `--cache-dir` or setting the appropriate 153 environment variable. 154 155 The cache has 4 different modes selected by `--vfs-cache-mode`. 156 The higher the cache mode the more compatible rclone becomes at the 157 cost of using disk space. 158 159 Note that files are written back to the remote only when they are 160 closed so if rclone is quit or dies with open files then these won't 161 get written back to the remote. However they will still be in the on 162 disk cache. 163 164 If using --vfs-cache-max-size note that the cache may exceed this size 165 for two reasons. Firstly because it is only checked every 166 --vfs-cache-poll-interval. Secondly because open files cannot be 167 evicted from the cache. 168 169 #### --vfs-cache-mode off 170 171 In this mode the cache will read directly from the remote and write 172 directly to the remote without caching anything on disk. 173 174 This will mean some operations are not possible 175 176 * Files can't be opened for both read AND write 177 * Files opened for write can't be seeked 178 * Existing files opened for write must have O_TRUNC set 179 * Files open for read with O_TRUNC will be opened write only 180 * Files open for write only will behave as if O_TRUNC was supplied 181 * Open modes O_APPEND, O_TRUNC are ignored 182 * If an upload fails it can't be retried 183 184 #### --vfs-cache-mode minimal 185 186 This is very similar to "off" except that files opened for read AND 187 write will be buffered to disks. This means that files opened for 188 write will be a lot more compatible, but uses the minimal disk space. 189 190 These operations are not possible 191 192 * Files opened for write only can't be seeked 193 * Existing files opened for write must have O_TRUNC set 194 * Files opened for write only will ignore O_APPEND, O_TRUNC 195 * If an upload fails it can't be retried 196 197 #### --vfs-cache-mode writes 198 199 In this mode files opened for read only are still read directly from 200 the remote, write only and read/write files are buffered to disk 201 first. 202 203 This mode should support all normal file system operations. 204 205 If an upload fails it will be retried up to --low-level-retries times. 206 207 #### --vfs-cache-mode full 208 209 In this mode all reads and writes are buffered to and from disk. When 210 a file is opened for read it will be downloaded in its entirety first. 211 212 This may be appropriate for your needs, or you may prefer to look at 213 the cache backend which does a much more sophisticated job of caching, 214 including caching directory hierarchies and chunks of files. 215 216 In this mode, unlike the others, when a file is written to the disk, 217 it will be kept on the disk after it is written to the remote. It 218 will be purged on a schedule according to `--vfs-cache-max-age`. 219 220 This mode should support all normal file system operations. 221 222 If an upload or download fails it will be retried up to 223 --low-level-retries times. 224 225 ### Auth Proxy 226 227 If you supply the parameter `--auth-proxy /path/to/program` then 228 rclone will use that program to generate backends on the fly which 229 then are used to authenticate incoming requests. This uses a simple 230 JSON based protocl with input on STDIN and output on STDOUT. 231 232 There is an example program 233 [bin/test_proxy.py](https://github.com/rclone/rclone/blob/master/test_proxy.py) 234 in the rclone source code. 235 236 The program's job is to take a `user` and `pass` on the input and turn 237 those into the config for a backend on STDOUT in JSON format. This 238 config will have any default parameters for the backend added, but it 239 won't use configuration from environment variables or command line 240 options - it is the job of the proxy program to make a complete 241 config. 242 243 This config generated must have this extra parameter 244 - `_root` - root to use for the backend 245 246 And it may have this parameter 247 - `_obscure` - comma separated strings for parameters to obscure 248 249 For example the program might take this on STDIN 250 251 ``` 252 { 253 "user": "me", 254 "pass": "mypassword" 255 } 256 ``` 257 258 And return this on STDOUT 259 260 ``` 261 { 262 "type": "sftp", 263 "_root": "", 264 "_obscure": "pass", 265 "user": "me", 266 "pass": "mypassword", 267 "host": "sftp.example.com" 268 } 269 ``` 270 271 This would mean that an SFTP backend would be created on the fly for 272 the `user` and `pass` returned in the output to the host given. Note 273 that since `_obscure` is set to `pass`, rclone will obscure the `pass` 274 parameter before creating the backend (which is required for sftp 275 backends). 276 277 The progam can manipulate the supplied `user` in any way, for example 278 to make proxy to many different sftp backends, you could make the 279 `user` be `user@example.com` and then set the `host` to `example.com` 280 in the output and the user to `user`. For security you'd probably want 281 to restrict the `host` to a limited list. 282 283 Note that an internal cache is keyed on `user` so only use that for 284 configuration, don't use `pass`. This also means that if a user's 285 password is changed the cache will need to expire (which takes 5 mins) 286 before it takes effect. 287 288 This can be used to build general purpose proxies to any kind of 289 backend that rclone supports. 290 291 292 ``` 293 rclone serve webdav remote:path [flags] 294 ``` 295 296 ### Options 297 298 ``` 299 --addr string IPaddress:Port or :Port to bind server to. (default "localhost:8080") 300 --auth-proxy string A program to use to create the backend from the auth. 301 --baseurl string Prefix for URLs - leave blank for root. 302 --cert string SSL PEM key (concatenation of certificate and CA certificate) 303 --client-ca string Client certificate authority to verify clients with 304 --dir-cache-time duration Time to cache directory entries for. (default 5m0s) 305 --dir-perms FileMode Directory permissions (default 0777) 306 --disable-dir-list Disable HTML directory list on GET request for a directory 307 --etag-hash string Which hash to use for the ETag, or auto or blank for off 308 --file-perms FileMode File permissions (default 0666) 309 --gid uint32 Override the gid field set by the filesystem. (default 1000) 310 -h, --help help for webdav 311 --htpasswd string htpasswd file - if not provided no authentication is done 312 --key string SSL PEM Private key 313 --max-header-bytes int Maximum size of request header (default 4096) 314 --no-checksum Don't compare checksums on up/download. 315 --no-modtime Don't read/write the modification time (can speed things up). 316 --no-seek Don't allow seeking in files. 317 --pass string Password for authentication. 318 --poll-interval duration Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable. (default 1m0s) 319 --read-only Mount read-only. 320 --realm string realm for authentication (default "rclone") 321 --server-read-timeout duration Timeout for server reading data (default 1h0m0s) 322 --server-write-timeout duration Timeout for server writing data (default 1h0m0s) 323 --uid uint32 Override the uid field set by the filesystem. (default 1000) 324 --umask int Override the permission bits set by the filesystem. (default 2) 325 --user string User name for authentication. 326 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 327 --vfs-cache-max-size SizeSuffix Max total size of objects in the cache. (default off) 328 --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) 329 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 330 --vfs-case-insensitive If a file name not found, find a case insensitive match. 331 --vfs-read-chunk-size SizeSuffix Read the source objects in chunks. (default 128M) 332 --vfs-read-chunk-size-limit SizeSuffix If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached. 'off' is unlimited. (default off) 333 ``` 334 335 See the [global flags page](/flags/) for global options not listed here. 336 337 ### SEE ALSO 338 339 * [rclone serve](/commands/rclone_serve/) - Serve a remote over a protocol. 340