github.com/ncw/rclone@v1.48.1-0.20190724201158-a35aa1360e3e/docs/content/commands/rclone_serve_http.md (about) 1 --- 2 date: 2019-06-20T16:09:42+01:00 3 title: "rclone serve http" 4 slug: rclone_serve_http 5 url: /commands/rclone_serve_http/ 6 --- 7 ## rclone serve http 8 9 Serve the remote over HTTP. 10 11 ### Synopsis 12 13 rclone serve http implements a basic web server to serve the remote 14 over HTTP. This can be viewed in a web browser or you can make a 15 remote of type http read from it. 16 17 You can use the filter flags (eg --include, --exclude) to control what 18 is served. 19 20 The server will log errors. Use -v to see access logs. 21 22 --bwlimit will be respected for file transfers. Use --stats to 23 control the stats printing. 24 25 ### Server options 26 27 Use --addr to specify which IP address and port the server should 28 listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all 29 IPs. By default it only listens on localhost. You can use port 30 :0 to let the OS choose an available port. 31 32 If you set --addr to listen on a public or LAN accessible IP address 33 then using Authentication is advised - see the next section for info. 34 35 --server-read-timeout and --server-write-timeout can be used to 36 control the timeouts on the server. Note that this is the total time 37 for a transfer. 38 39 --max-header-bytes controls the maximum number of bytes the server will 40 accept in the HTTP header. 41 42 #### Authentication 43 44 By default this will serve files without needing a login. 45 46 You can either use an htpasswd file which can take lots of users, or 47 set a single username and password with the --user and --pass flags. 48 49 Use --htpasswd /path/to/htpasswd to provide an htpasswd file. This is 50 in standard apache format and supports MD5, SHA1 and BCrypt for basic 51 authentication. Bcrypt is recommended. 52 53 To create an htpasswd file: 54 55 touch htpasswd 56 htpasswd -B htpasswd user 57 htpasswd -B htpasswd anotherUser 58 59 The password file can be updated while rclone is running. 60 61 Use --realm to set the authentication realm. 62 63 #### SSL/TLS 64 65 By default this will serve over http. If you want you can serve over 66 https. You will need to supply the --cert and --key flags. If you 67 wish to do client side certificate validation then you will need to 68 supply --client-ca also. 69 70 --cert should be a either a PEM encoded certificate or a concatenation 71 of that with the CA certificate. --key should be the PEM encoded 72 private key and --client-ca should be the PEM encoded client 73 certificate authority certificate. 74 75 ### Directory Cache 76 77 Using the `--dir-cache-time` flag, you can set how long a 78 directory should be considered up to date and not refreshed from the 79 backend. Changes made locally in the mount may appear immediately or 80 invalidate the cache. However, changes done on the remote will only 81 be picked up once the cache expires. 82 83 Alternatively, you can send a `SIGHUP` signal to rclone for 84 it to flush all directory caches, regardless of how old they are. 85 Assuming only one rclone instance is running, you can reset the cache 86 like this: 87 88 kill -SIGHUP $(pidof rclone) 89 90 If you configure rclone with a [remote control](/rc) then you can use 91 rclone rc to flush the whole directory cache: 92 93 rclone rc vfs/forget 94 95 Or individual files or directories: 96 97 rclone rc vfs/forget file=path/to/file dir=path/to/dir 98 99 ### File Buffering 100 101 The `--buffer-size` flag determines the amount of memory, 102 that will be used to buffer data in advance. 103 104 Each open file descriptor will try to keep the specified amount of 105 data in memory at all times. The buffered data is bound to one file 106 descriptor and won't be shared between multiple open file descriptors 107 of the same file. 108 109 This flag is a upper limit for the used memory per file descriptor. 110 The buffer will only use memory for data that is downloaded but not 111 not yet read. If the buffer is empty, only a small amount of memory 112 will be used. 113 The maximum memory used by rclone for buffering can be up to 114 `--buffer-size * open files`. 115 116 ### File Caching 117 118 These flags control the VFS file caching options. The VFS layer is 119 used by rclone mount to make a cloud storage system work more like a 120 normal file system. 121 122 You'll need to enable VFS caching if you want, for example, to read 123 and write simultaneously to a file. See below for more details. 124 125 Note that the VFS cache works in addition to the cache backend and you 126 may find that you need one or the other or both. 127 128 --cache-dir string Directory rclone will use for caching. 129 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 130 --vfs-cache-mode string Cache mode off|minimal|writes|full (default "off") 131 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 132 --vfs-cache-max-size int Max total size of objects in the cache. (default off) 133 134 If run with `-vv` rclone will print the location of the file cache. The 135 files are stored in the user cache file area which is OS dependent but 136 can be controlled with `--cache-dir` or setting the appropriate 137 environment variable. 138 139 The cache has 4 different modes selected by `--vfs-cache-mode`. 140 The higher the cache mode the more compatible rclone becomes at the 141 cost of using disk space. 142 143 Note that files are written back to the remote only when they are 144 closed so if rclone is quit or dies with open files then these won't 145 get written back to the remote. However they will still be in the on 146 disk cache. 147 148 If using --vfs-cache-max-size note that the cache may exceed this size 149 for two reasons. Firstly because it is only checked every 150 --vfs-cache-poll-interval. Secondly because open files cannot be 151 evicted from the cache. 152 153 #### --vfs-cache-mode off 154 155 In this mode the cache will read directly from the remote and write 156 directly to the remote without caching anything on disk. 157 158 This will mean some operations are not possible 159 160 * Files can't be opened for both read AND write 161 * Files opened for write can't be seeked 162 * Existing files opened for write must have O_TRUNC set 163 * Files open for read with O_TRUNC will be opened write only 164 * Files open for write only will behave as if O_TRUNC was supplied 165 * Open modes O_APPEND, O_TRUNC are ignored 166 * If an upload fails it can't be retried 167 168 #### --vfs-cache-mode minimal 169 170 This is very similar to "off" except that files opened for read AND 171 write will be buffered to disks. This means that files opened for 172 write will be a lot more compatible, but uses the minimal disk space. 173 174 These operations are not possible 175 176 * Files opened for write only can't be seeked 177 * Existing files opened for write must have O_TRUNC set 178 * Files opened for write only will ignore O_APPEND, O_TRUNC 179 * If an upload fails it can't be retried 180 181 #### --vfs-cache-mode writes 182 183 In this mode files opened for read only are still read directly from 184 the remote, write only and read/write files are buffered to disk 185 first. 186 187 This mode should support all normal file system operations. 188 189 If an upload fails it will be retried up to --low-level-retries times. 190 191 #### --vfs-cache-mode full 192 193 In this mode all reads and writes are buffered to and from disk. When 194 a file is opened for read it will be downloaded in its entirety first. 195 196 This may be appropriate for your needs, or you may prefer to look at 197 the cache backend which does a much more sophisticated job of caching, 198 including caching directory hierarchies and chunks of files. 199 200 In this mode, unlike the others, when a file is written to the disk, 201 it will be kept on the disk after it is written to the remote. It 202 will be purged on a schedule according to `--vfs-cache-max-age`. 203 204 This mode should support all normal file system operations. 205 206 If an upload or download fails it will be retried up to 207 --low-level-retries times. 208 209 210 ``` 211 rclone serve http remote:path [flags] 212 ``` 213 214 ### Options 215 216 ``` 217 --addr string IPaddress:Port or :Port to bind server to. (default "localhost:8080") 218 --cert string SSL PEM key (concatenation of certificate and CA certificate) 219 --client-ca string Client certificate authority to verify clients with 220 --dir-cache-time duration Time to cache directory entries for. (default 5m0s) 221 --dir-perms FileMode Directory permissions (default 0777) 222 --file-perms FileMode File permissions (default 0666) 223 --gid uint32 Override the gid field set by the filesystem. (default 1000) 224 -h, --help help for http 225 --htpasswd string htpasswd file - if not provided no authentication is done 226 --key string SSL PEM Private key 227 --max-header-bytes int Maximum size of request header (default 4096) 228 --no-checksum Don't compare checksums on up/download. 229 --no-modtime Don't read/write the modification time (can speed things up). 230 --no-seek Don't allow seeking in files. 231 --pass string Password for authentication. 232 --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) 233 --read-only Mount read-only. 234 --realm string realm for authentication (default "rclone") 235 --server-read-timeout duration Timeout for server reading data (default 1h0m0s) 236 --server-write-timeout duration Timeout for server writing data (default 1h0m0s) 237 --uid uint32 Override the uid field set by the filesystem. (default 1000) 238 --umask int Override the permission bits set by the filesystem. (default 2) 239 --user string User name for authentication. 240 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 241 --vfs-cache-max-size SizeSuffix Max total size of objects in the cache. (default off) 242 --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) 243 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 244 --vfs-read-chunk-size SizeSuffix Read the source objects in chunks. (default 128M) 245 --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) 246 ``` 247 248 See the [global flags page](/flags/) for global options not listed here. 249 250 ### SEE ALSO 251 252 * [rclone serve](/commands/rclone_serve/) - Serve a remote over a protocol. 253