Hello Francis,
It seems that your solution working as expected and I have started to test it. Also, have some questions here:
1. "~*" to be "~^"
The first one looks like Nginx regexp we can use for locations, but the second one not (^~): https://www.digitalocean.com/community/tutorials/understanding-nginx-server-and-location-block-selection-algorithms
2. It seems that the order of records in map is important. We pass required queries with args, we block then all queries with args and allow without args a then default value is applied. Maybe you can provide more details here.
Thank you for help and for the ready solution!