Thank you Reinis - that did it :)
Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,285363,285374#msg-285374
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
> Is this expected behaviour? Could there be another way to do this?
'if' (the rewrite module) is executed in early stages when $sent_* variables
are not available that’s why the regex doesn't match.
What you could do is use 'map' instead:
(http://nginx.org/en/docs/http/ngx_http_map_module.html