Thanks a lot Francis! Now I just have to learn how to use the custom variables and the "map" directive. I haven't ever used them before, never needed them.
By the way, it will be easier than what I thought. I decided to ask my users to add an extra parameter, something like "&capacity=3X" instead of "hiding" some characters in the key that would indicate what to do. So at least I wont have to make a lot of effort with the regular expressions, the parameter will be very clear. My logic will chech its value and apply the respective limit.
Its interesting how weird is the configuration of Nginx. No XML tags, but weird directives that are not really straightforward.