I have a question that I assume is recurring, but I can’t find an answer in the forum search.
We limit push size with Admin → Settings → Account and limit → Maximum push size
But that doesn’t apply to the Web UI, and we have users occasionally erroneously uploading large files that way. Is there a way to limit the size of Web UI uploads?
Unfortunately, it looks like nginx[‘client_max_body_size’] would also restrict the API, which we don’t want to do. We’re looking for a fix specific to restricting the size of uploads through the Web UI.
You can limit Web UI upload size by configuring your web server. If you’re using NGINX, update the client_max_body_size setting in your config file. For Apache, you can use LimitRequestBody to restrict file sizes. Unfortunately, GitLab doesn’t have a built-in setting for this, so adjusting your server configuration is the best approach.
@jacoboliverleo, unfortunately nginx[‘client_max_body_size’] also restricts the API, which we don’t want to do – we’re looking for a fix that’s specific to restricting the size of uploads through the Web UI.
The inability to restrict this does appear to be an important config omission.
and within that file, configure location block for /api but with different value for client_max_body_size that is higher than the one already mentioned. You’ll then limit the web interface just as you want, with also having a different value for /api.
Reviewing the compiled NGINX file at /var/opt/gitlab/nginx/conf/gitlab-http.conf,
I notice that Gitlab puts these custom rules at the end of the config. Therefore when regex is used, the main /api/v4 route is picked up first (I believe per nginx match ordering).
Yeah, that’s the tricky part , nginx[‘client_max_body_size’] affects both the Web UI and API, so it’s not ideal if you only want to limit UI uploads.
As far as I know, GitLab doesn’t currently support separate limits for just the Web UI. A possible workaround could be a reverse proxy or middleware that filters by route and applies size limits just to upload endpoints. Not perfect, but it gives a bit more control.