@partha did you ever find a lasting solution for max_size as a plugin?
@regis, I’m by no means an expert in the plugins system but having had a look at the template and the list of available patches, it appears to me that the max_size value is hard coded into the template and so cannot be defined by a patch as that will simply add a value to CaddyFile instead of overwriting the defaults, this might break syntax or at the very least introduce duplication of directives for Caddy. (thinking back to running apache/nginx sites in the past these kind of things can cause issues but it’s been a long time since I did, I’m anticipating that Caddy might behave similarly)
Additionally, insofar as I can tell, the following patch (unless I misunderstood it’s function) has no effect in relation to Caddy’s max_size directive (whether or not that’s how it’s supposed to be I’m unsure)
openedx-cms-production-settings: |
MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB
I think I might have some ideas how to work around this but not sure how/if it would interact with anything in unexpected ways. Note I have not tested any of this, it’s just theory I came up with in my head, please don’t implement unless I’m not a complete idiot (see footnote at bottom)
Possible option:
Add new patch directives for each max_size value in the template, example:
{{ LMS_HOST }}{$default_site_port}, {{ PREVIEW_LMS_HOST }}{$default_site_port} {
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico
# Limit profile image upload size
handle_path /api/profile_images/*/*/upload {
request_body {
{{ patch("caddyfile-lms-profile_images_max_size")|indent(4) }}
}
}
import proxy "lms:8000"
{{ patch("caddyfile-lms")|indent(4) }}
handle_path /* {
request_body {
{{ patch("caddyfile-lms-max_size")|indent(4) }}
}
}
}
{{ CMS_HOST }}{$default_site_port} {
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico
import proxy "cms:8000"
{{ patch("caddyfile-cms")|indent(4) }}
handle_path /* {
request_body {
{{ patch("caddyfile-cms-max_size")|indent(4) }}
}
}
}
Though if my understanding is right this will break the build for everyone who is NOT using a patch as it won’t have default values to assign.
Perhaps default values can be kept in the file with a condition (similar to the Global config at the top like {% if not ENABLE_WEB_PROXY %}) where we can have an option in config.yml to choose
eg: CADDYFILE_USEDEFAULT_MAX_SIZE: [true|false] (where false implies to use patch and true specifies use built-in defaults.
Maybe something like this?:
{{ CMS_HOST }}{$default_site_port} {
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico
import proxy "cms:8000"
{{ patch("caddyfile-cms")|indent(4) }}
handle_path /* {
request_body {
{% if not CADDYFILE_USEDEFAULT_MAX_SIZE %}
max_size 250MB
{% else %}
{{ patch("caddyfile-cms-max_size")|indent(4) }}
{% endif %}
}
}
}
Though please DO assume that I might be an idiot who doesn’t know what they’re talking about, my level of expertise with caddy/tutor is not great, this is all guesswork. The patch/variable names I supplied are for illustrative purposes and not intended to be a final suggestion