Merge pull request #70 from snikket-im/http-upload-limits

New HTTP upload limits and quota
This commit is contained in:
Matthew Wild 2021-10-14 14:52:17 +01:00 committed by GitHub
commit 0ce5d3acf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,7 @@
local DOMAIN = assert(ENV_SNIKKET_DOMAIN, "Please set the SNIKKET_DOMAIN environment variable")
local RETENTION_DAYS = tonumber(ENV_SNIKKET_RETENTION_DAYS) or 7;
local UPLOAD_STORAGE_GB = tonumber(ENV_SNIKKET_UPLOAD_STORAGE_GB);
if prosody.process_type == "prosody" and not prosody.config_loaded then
-- Wait at startup for certificates
@ -261,8 +262,11 @@ Component ("share."..DOMAIN) "http_file_share"
http_host = "share."..DOMAIN
http_external_url = "https://share."..DOMAIN.."/"
end
http_file_share_size_limit = 1024 * 1024 * 16 -- 16MB
http_file_share_size_limit = 1024 * 1024 * 100 -- 100MB
http_file_share_expire_after = 60 * 60 * 24 * RETENTION_DAYS -- N days
if UPLOAD_STORAGE_GB then
http_file_share_global_quota = 1024 * 1024 * 1024 * UPLOAD_STORAGE_GB
end
http_paths = {
file_share = "/upload"
}

View File

@ -35,6 +35,21 @@ On the other hand, storing too many messages on the server causes impacts on ser
Changing this option to a lower value will delete messages from the server. Changing this option to a higher value will allow messages existing on the server to be retained for longer.
### `SNIKKET_UPLOAD_STORAGE_GB`
Use this option to place a limit on the amount of storage Snikket will use for files shared by users. You can use this to prevent your server's disk capacity being consumed if users upload many large files. By default there is no limit.
If the limit is reached, users will be unable to upload new files until older files are cleared by Snikket after the configured retention period (or the limit is increased).
Example:
```
# Allow no more than 1.5GB disk space to be used by uploaded files
SNIKKET_UPLOAD_STORAGE_GB=1.5
```
The amount of file storage used is affected by the configured retention period (7 days by default) - i.e. longer retention periods will mean files are stored for longer, and more space will be used. Take this into account when choosing a value.
### `SNIKKET_LOGLEVEL`
Control the detail level of the log output of the snikket server.