github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/docs/content/commands/rclone_serve_http.md (about) 1 --- 2 title: "rclone serve http" 3 description: "Serve the remote over HTTP." 4 slug: rclone_serve_http 5 url: /commands/rclone_serve_http/ 6 # autogenerated - DO NOT EDIT, instead edit the source code in cmd/serve/http/ and as part of making a release run "make commanddocs" 7 --- 8 # rclone serve http 9 10 Serve the remote over HTTP. 11 12 ## Synopsis 13 14 rclone serve http implements a basic web server to serve the remote 15 over HTTP. This can be viewed in a web browser or you can make a 16 remote of type http read from it. 17 18 You can use the filter flags (eg --include, --exclude) to control what 19 is served. 20 21 The server will log errors. Use -v to see access logs. 22 23 --bwlimit will be respected for file transfers. Use --stats to 24 control the stats printing. 25 26 ## Server options 27 28 Use --addr to specify which IP address and port the server should 29 listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all 30 IPs. By default it only listens on localhost. You can use port 31 :0 to let the OS choose an available port. 32 33 If you set --addr to listen on a public or LAN accessible IP address 34 then using Authentication is advised - see the next section for info. 35 36 --server-read-timeout and --server-write-timeout can be used to 37 control the timeouts on the server. Note that this is the total time 38 for a transfer. 39 40 --max-header-bytes controls the maximum number of bytes the server will 41 accept in the HTTP header. 42 43 --baseurl controls the URL prefix that rclone serves from. By default 44 rclone will serve from the root. If you used --baseurl "/rclone" then 45 rclone would serve from a URL starting with "/rclone/". This is 46 useful if you wish to proxy rclone serve. Rclone automatically 47 inserts leading and trailing "/" on --baseurl, so --baseurl "rclone", 48 --baseurl "/rclone" and --baseurl "/rclone/" are all treated 49 identically. 50 51 --template allows a user to specify a custom markup template for http 52 and webdav serve functions. The server exports the following markup 53 to be used within the template to server pages: 54 55 | Parameter | Description | 56 | :---------- | :---------- | 57 | .Name | The full path of a file/directory. | 58 | .Title | Directory listing of .Name | 59 | .Sort | The current sort used. This is changeable via ?sort= parameter | 60 | | Sort Options: namedirfist,name,size,time (default namedirfirst) | 61 | .Order | The current ordering used. This is changeable via ?order= parameter | 62 | | Order Options: asc,desc (default asc) | 63 | .Query | Currently unused. | 64 | .Breadcrumb | Allows for creating a relative navigation | 65 |-- .Link | The relative to the root link of the Text. | 66 |-- .Text | The Name of the directory. | 67 | .Entries | Information about a specific file/directory. | 68 |-- .URL | The 'url' of an entry. | 69 |-- .Leaf | Currently same as 'URL' but intended to be 'just' the name. | 70 |-- .IsDir | Boolean for if an entry is a directory or not. | 71 |-- .Size | Size in Bytes of the entry. | 72 |-- .ModTime | The UTC timestamp of an entry. | 73 74 ### Authentication 75 76 By default this will serve files without needing a login. 77 78 You can either use an htpasswd file which can take lots of users, or 79 set a single username and password with the --user and --pass flags. 80 81 Use --htpasswd /path/to/htpasswd to provide an htpasswd file. This is 82 in standard apache format and supports MD5, SHA1 and BCrypt for basic 83 authentication. Bcrypt is recommended. 84 85 To create an htpasswd file: 86 87 touch htpasswd 88 htpasswd -B htpasswd user 89 htpasswd -B htpasswd anotherUser 90 91 The password file can be updated while rclone is running. 92 93 Use --realm to set the authentication realm. 94 95 ### SSL/TLS 96 97 By default this will serve over http. If you want you can serve over 98 https. You will need to supply the --cert and --key flags. If you 99 wish to do client side certificate validation then you will need to 100 supply --client-ca also. 101 102 --cert should be either a PEM encoded certificate or a concatenation 103 of that with the CA certificate. --key should be the PEM encoded 104 private key and --client-ca should be the PEM encoded client 105 certificate authority certificate. 106 107 ## Directory Cache 108 109 Using the `--dir-cache-time` flag, you can set how long a 110 directory should be considered up to date and not refreshed from the 111 backend. Changes made locally in the mount may appear immediately or 112 invalidate the cache. However, changes done on the remote will only 113 be picked up once the cache expires if the backend configured does not 114 support polling for changes. If the backend supports polling, changes 115 will be picked up on within the polling interval. 116 117 Alternatively, you can send a `SIGHUP` signal to rclone for 118 it to flush all directory caches, regardless of how old they are. 119 Assuming only one rclone instance is running, you can reset the cache 120 like this: 121 122 kill -SIGHUP $(pidof rclone) 123 124 If you configure rclone with a [remote control](/rc) then you can use 125 rclone rc to flush the whole directory cache: 126 127 rclone rc vfs/forget 128 129 Or individual files or directories: 130 131 rclone rc vfs/forget file=path/to/file dir=path/to/dir 132 133 ## File Buffering 134 135 The `--buffer-size` flag determines the amount of memory, 136 that will be used to buffer data in advance. 137 138 Each open file descriptor will try to keep the specified amount of 139 data in memory at all times. The buffered data is bound to one file 140 descriptor and won't be shared between multiple open file descriptors 141 of the same file. 142 143 This flag is a upper limit for the used memory per file descriptor. 144 The buffer will only use memory for data that is downloaded but not 145 not yet read. If the buffer is empty, only a small amount of memory 146 will be used. 147 The maximum memory used by rclone for buffering can be up to 148 `--buffer-size * open files`. 149 150 ## File Caching 151 152 These flags control the VFS file caching options. The VFS layer is 153 used by rclone mount to make a cloud storage system work more like a 154 normal file system. 155 156 You'll need to enable VFS caching if you want, for example, to read 157 and write simultaneously to a file. See below for more details. 158 159 Note that the VFS cache works in addition to the cache backend and you 160 may find that you need one or the other or both. 161 162 --cache-dir string Directory rclone will use for caching. 163 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 164 --vfs-cache-mode string Cache mode off|minimal|writes|full (default "off") 165 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 166 --vfs-cache-max-size int Max total size of objects in the cache. (default off) 167 168 If run with `-vv` rclone will print the location of the file cache. The 169 files are stored in the user cache file area which is OS dependent but 170 can be controlled with `--cache-dir` or setting the appropriate 171 environment variable. 172 173 The cache has 4 different modes selected by `--vfs-cache-mode`. 174 The higher the cache mode the more compatible rclone becomes at the 175 cost of using disk space. 176 177 Note that files are written back to the remote only when they are 178 closed so if rclone is quit or dies with open files then these won't 179 get written back to the remote. However they will still be in the on 180 disk cache. 181 182 If using --vfs-cache-max-size note that the cache may exceed this size 183 for two reasons. Firstly because it is only checked every 184 --vfs-cache-poll-interval. Secondly because open files cannot be 185 evicted from the cache. 186 187 ### --vfs-cache-mode off 188 189 In this mode the cache will read directly from the remote and write 190 directly to the remote without caching anything on disk. 191 192 This will mean some operations are not possible 193 194 * Files can't be opened for both read AND write 195 * Files opened for write can't be seeked 196 * Existing files opened for write must have O_TRUNC set 197 * Files open for read with O_TRUNC will be opened write only 198 * Files open for write only will behave as if O_TRUNC was supplied 199 * Open modes O_APPEND, O_TRUNC are ignored 200 * If an upload fails it can't be retried 201 202 ### --vfs-cache-mode minimal 203 204 This is very similar to "off" except that files opened for read AND 205 write will be buffered to disks. This means that files opened for 206 write will be a lot more compatible, but uses the minimal disk space. 207 208 These operations are not possible 209 210 * Files opened for write only can't be seeked 211 * Existing files opened for write must have O_TRUNC set 212 * Files opened for write only will ignore O_APPEND, O_TRUNC 213 * If an upload fails it can't be retried 214 215 ### --vfs-cache-mode writes 216 217 In this mode files opened for read only are still read directly from 218 the remote, write only and read/write files are buffered to disk 219 first. 220 221 This mode should support all normal file system operations. 222 223 If an upload fails it will be retried up to --low-level-retries times. 224 225 ### --vfs-cache-mode full 226 227 In this mode all reads and writes are buffered to and from disk. When 228 a file is opened for read it will be downloaded in its entirety first. 229 230 This may be appropriate for your needs, or you may prefer to look at 231 the cache backend which does a much more sophisticated job of caching, 232 including caching directory hierarchies and chunks of files. 233 234 In this mode, unlike the others, when a file is written to the disk, 235 it will be kept on the disk after it is written to the remote. It 236 will be purged on a schedule according to `--vfs-cache-max-age`. 237 238 This mode should support all normal file system operations. 239 240 If an upload or download fails it will be retried up to 241 --low-level-retries times. 242 243 ## Case Sensitivity 244 245 Linux file systems are case-sensitive: two files can differ only 246 by case, and the exact case must be used when opening a file. 247 248 Windows is not like most other operating systems supported by rclone. 249 File systems in modern Windows are case-insensitive but case-preserving: 250 although existing files can be opened using any case, the exact case used 251 to create the file is preserved and available for programs to query. 252 It is not allowed for two files in the same directory to differ only by case. 253 254 Usually file systems on macOS are case-insensitive. It is possible to make macOS 255 file systems case-sensitive but that is not the default 256 257 The "--vfs-case-insensitive" mount flag controls how rclone handles these 258 two cases. If its value is "false", rclone passes file names to the mounted 259 file system as is. If the flag is "true" (or appears without a value on 260 command line), rclone may perform a "fixup" as explained below. 261 262 The user may specify a file name to open/delete/rename/etc with a case 263 different than what is stored on mounted file system. If an argument refers 264 to an existing file with exactly the same name, then the case of the existing 265 file on the disk will be used. However, if a file name with exactly the same 266 name is not found but a name differing only by case exists, rclone will 267 transparently fixup the name. This fixup happens only when an existing file 268 is requested. Case sensitivity of file names created anew by rclone is 269 controlled by an underlying mounted file system. 270 271 Note that case sensitivity of the operating system running rclone (the target) 272 may differ from case sensitivity of a file system mounted by rclone (the source). 273 The flag controls whether "fixup" is performed to satisfy the target. 274 275 If the flag is not provided on command line, then its default value depends 276 on the operating system where rclone runs: "true" on Windows and macOS, "false" 277 otherwise. If the flag is provided without a value, then it is "true". 278 279 280 ``` 281 rclone serve http remote:path [flags] 282 ``` 283 284 ## Options 285 286 ``` 287 --addr string IPaddress:Port or :Port to bind server to. (default "localhost:8080") 288 --baseurl string Prefix for URLs - leave blank for root. 289 --cert string SSL PEM key (concatenation of certificate and CA certificate) 290 --client-ca string Client certificate authority to verify clients with 291 --dir-cache-time duration Time to cache directory entries for. (default 5m0s) 292 --dir-perms FileMode Directory permissions (default 0777) 293 --file-perms FileMode File permissions (default 0666) 294 --gid uint32 Override the gid field set by the filesystem. (default 1000) 295 -h, --help help for http 296 --htpasswd string htpasswd file - if not provided no authentication is done 297 --key string SSL PEM Private key 298 --max-header-bytes int Maximum size of request header (default 4096) 299 --no-checksum Don't compare checksums on up/download. 300 --no-modtime Don't read/write the modification time (can speed things up). 301 --no-seek Don't allow seeking in files. 302 --pass string Password for authentication. 303 --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) 304 --read-only Mount read-only. 305 --realm string realm for authentication (default "rclone") 306 --server-read-timeout duration Timeout for server reading data (default 1h0m0s) 307 --server-write-timeout duration Timeout for server writing data (default 1h0m0s) 308 --template string User Specified Template. 309 --uid uint32 Override the uid field set by the filesystem. (default 1000) 310 --umask int Override the permission bits set by the filesystem. (default 2) 311 --user string User name for authentication. 312 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 313 --vfs-cache-max-size SizeSuffix Max total size of objects in the cache. (default off) 314 --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) 315 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 316 --vfs-case-insensitive If a file name not found, find a case insensitive match. 317 --vfs-read-chunk-size SizeSuffix Read the source objects in chunks. (default 128M) 318 --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) 319 --vfs-read-wait duration Time to wait for in-sequence read before seeking. (default 20ms) 320 --vfs-write-wait duration Time to wait for in-sequence write before giving error. (default 1s) 321 ``` 322 323 See the [global flags page](/flags/) for global options not listed here. 324 325 ## SEE ALSO 326 327 * [rclone serve](/commands/rclone_serve/) - Serve a remote over a protocol. 328