rewrite and map ??interfering regexps

Norman Gray gray at nxg.name
Sun Apr 26 19:03:18 UTC 2020


Maxim, hello.

On 26 Apr 2020, at 17:28, Maxim Dounin wrote:

> Relevant ticket is here:
>
> https://trac.nginx.org/nginx/ticket/564
>
> Unfortunately, there is no obvious solution.  On the other hand,
> this is something relatively easy to work around.

Aha, so it _is_ the map regexp and the rewrite regexp mutually 
interfering!  Thanks for the speedy insight.

Looking through the comments in the ticket, I agree with you that 'the 
current behaviour is bad, and should be fixed'.  If only on a principle 
of least surprise.

Until it is fixed, however, it would be extremely useful if, in the 
description of the 'map' stanza (ie, in 
<https://nginx.org/en/docs/http/ngx_http_map_module.html>) it mentioned 
that the regexp in 'map' can interfere with the regexp in a 'rewrite' 
directive, in such a way that positional groups in the latter don't 
work.  It could note that this is a (temporary?) defect, but that until 
it is fixed, using named groups in the 'rewrite' regexp is a good 
workaround, and give an example.

It would be better here than in the documentation of 'rewrite', as that 
would keep the 'rewrite' documentation relatively simple.  It only needs 
to be seen by people using 'rewrite' and 'map' together, who might be 
assumed to be marginally more sophisticated users.

Best wishes,

Norman


-- 
Norman Gray  :  https://nxg.me.uk


More information about the nginx mailing list