Score:0

unrecognized character follows \ in "\index.htm(l?)" after updating to nginx 1.21.5

vn flag

My docker image has suddenly failed after build with error message:

2021/12/30 16:02:26 [emerg] 16#16: pcre2_compile() failed: unrecognized character follows \ in "\index.htm(l?)" at "index.htm(l?)" in /etc/nginx/conf.d/default.conf:37

We are building docker image from nginx:latest, which is currently 1.21.5.

I've degraded to nginx 1.21.4 and it starts without an issue.

My problematic configuration is:

    location ~* \index.htm(l?) {
        add_header Cache-Control 'no-cache, no-store, must-revalidate';
    }

Was there any breaking change indroduced between nginx 1.12.4 and 1.12.5, or I was using a deprecated syntax? I've never got any warning about it.

jp flag
And have \i at the start of the regexp. It is an unknown escape sequence.
Score:1
kz flag

In the release notes they state that it is now "built with the PCRE2 library by default". Perhaps this is stricter when parsing unknown escape sequences than before.

https://nginx.org/en/CHANGES

Score:1
vn flag

Thanks to AlexD comment I've found out the actual problem:

The change in the nginx 1.21.5 is switching from PCRE to PCRE2. PCRE2 is compatible with previous version, except it's not tolerant against many errors that were ignored by previous version.

The problem in my case was 'escaping' of the first letter, which was not correct escaping (copy-paste from another case, where the dot was escaped).

PCRE has silently ignored 'escaping' and processed regex as if '' were not present.

PCRE2 throws error.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.