How to update Caddyfile using tutor plugin

I am trying to increase the upload content size. Default size is 100MB.
I am trying to change it to 500MB.
I am able to change in the openedx-cms-production-settings using tutor plugin.
I have to update the same in Caddyfile located at the the location “$(tutor config printroot)/env/apps/caddy/Caddyfile” for the following entry studio.lms-dev.techsophy.com{$default_site_port}
I have directly edited the file and changed the value of max_size to 500MB and it is working.

How to I apply this change using tutor plugin? Need some hint

Hello @partha, welcome!

There are several patch hooks in the Caddyfile you can take advantage in a plugin. For instance, caddyfile-cms. I’m no Caddy expert, but I believe you could create a plugin like so, and it would get you what you need:

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "caddyfile-cms",
        """
    request_body {
        max_size 500MB
    }
"""
    )
)

Let us know if it works!

I don’t think using tutor plugin would work because the request_body.max_size is appended at the bottom of the settings and it will be ignored by the default value.

One workaround way that I can think about is to modify the tutor Caddyfile template at
/home/ubuntu/.local/lib/python3.8/site-packages/tutor/templates/apps/caddy/Caddyfile
but you have to manually set this value everytime you upgrade tutor.

@partha can you please check whether implementing the “caddyfile-cms” and “caddyfile-lms” patches works for you? If not, would they work if the patch was located before the import proxy "lms:8000"/import proxy "cms:8000" statements?

The plugin did not work though the Caddy file was updated as bellow

 request_body {
        max_size 250MB
    }

    import proxy "cms:8000"


        request_body {
            max_size 500MB
        }

Even after modifying the Caddyfiles as suggested by @regis it did not work. Following are the changes I made.
I have manually edited the Caddyfile at location
“$(tutor config printroot)/env/apps/caddy/Caddyfile”
moved the request_body section before import as shown bellow

request_body {
            max_size 500MB
        }
    import proxy "cms:8000"

Thank you @partha. And you did restart caddy every time to take your changes into account, right? (tutor local restart caddy)

Yes I did restart the services after the changes.

Sorry it took me so long to get back to you @partha. I propose that we move the “caddyfile-cms” and “caddyfile-lms” patches just before the import proxy line. I believe this should resolve your issue, as you would be able to create a patch that overrides the max_size. Right?

EDIT: see this pull request feat: overridable lms/cms max upload size by regisb · Pull Request #792 · overhangio/tutor · GitHub As explained in the PR description, once it is merged you should be able to modify the upload max size by adding the following to the “caddyfile-cms” patch:

handle_path /import/* {
    request_body {
        max_size 500MB
    }
}
1 Like

YES! @regis that would solve the issue we currently have and that I mentioned way back in Caddy issues with ID Verification

Thank you!