From 6852c3711191e690c98b169911824b4d5c44204c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 14 Oct 2021 14:14:48 +0100 Subject: [PATCH 1/4] prosody: Bump per-upload limit from 16MB to 100MB --- ansible/files/prosody.cfg.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/files/prosody.cfg.lua b/ansible/files/prosody.cfg.lua index 71cbe68..5075883 100644 --- a/ansible/files/prosody.cfg.lua +++ b/ansible/files/prosody.cfg.lua @@ -261,7 +261,7 @@ 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 http_paths = { file_share = "/upload" From 03f0bb2bd926a633e0ef545d935e9630adca3242 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 14 Oct 2021 14:16:04 +0100 Subject: [PATCH 2/4] prosody: Allow configuration of global upload storage quota --- ansible/files/prosody.cfg.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/files/prosody.cfg.lua b/ansible/files/prosody.cfg.lua index 5075883..f1034a0 100644 --- a/ansible/files/prosody.cfg.lua +++ b/ansible/files/prosody.cfg.lua @@ -263,6 +263,9 @@ Component ("share."..DOMAIN) "http_file_share" end http_file_share_size_limit = 1024 * 1024 * 100 -- 100MB http_file_share_expire_after = 60 * 60 * 24 * RETENTION_DAYS -- N days + if ENV_SNIKKET_UPLOAD_STORAGE_GB and tonumber(ENV_SNIKKET_UPLOAD_STORAGE_GB) then + http_file_share_global_quota = 1024 * 1024 * 1024 * tonumber(ENV_SNIKKET_UPLOAD_STORAGE_GB) + end http_paths = { file_share = "/upload" } From 88b61461cc0e518c92af12e5415382afd60ab0e3 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 14 Oct 2021 14:35:42 +0100 Subject: [PATCH 3/4] prosody: more consistent environment variable import --- ansible/files/prosody.cfg.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ansible/files/prosody.cfg.lua b/ansible/files/prosody.cfg.lua index f1034a0..d531fc1 100644 --- a/ansible/files/prosody.cfg.lua +++ b/ansible/files/prosody.cfg.lua @@ -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 @@ -263,8 +264,8 @@ Component ("share."..DOMAIN) "http_file_share" end http_file_share_size_limit = 1024 * 1024 * 100 -- 100MB http_file_share_expire_after = 60 * 60 * 24 * RETENTION_DAYS -- N days - if ENV_SNIKKET_UPLOAD_STORAGE_GB and tonumber(ENV_SNIKKET_UPLOAD_STORAGE_GB) then - http_file_share_global_quota = 1024 * 1024 * 1024 * tonumber(ENV_SNIKKET_UPLOAD_STORAGE_GB) + if UPLOAD_STORAGE_GB then + http_file_share_global_quota = 1024 * 1024 * 1024 * UPLOAD_STORAGE_GB end http_paths = { file_share = "/upload" From c02b8b7f3f607d2dc32adf951a7c560a4ab85aca Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 14 Oct 2021 14:50:22 +0100 Subject: [PATCH 4/4] docs/advanced/config: document new SNIKKET_UPLOAD_STORAGE_GB option --- docs/advanced/config.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/advanced/config.md b/docs/advanced/config.md index a4a0fc8..6ff684c 100644 --- a/docs/advanced/config.md +++ b/docs/advanced/config.md @@ -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.