N
N
Nastradamus2013-07-04 11:43:06
Nginx
Nastradamus, 2013-07-04 11:43:06

nginx. The condition in curly braces of the regular expression does not work

Hello! I'm confused about something...

I write the following condition in location /:

if ($request ~* "/products/detail.php\?ID=.{7}")
{
access_log /var/log/nginx.error_log;
return 403;
}


After that, nginx starts blocking requests like:

/products/detail.php?ID=142

That is, the condition "if the characters after = is greater than or equal to 7" does not work.

Please advise.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
avalak, 2013-07-04
@avalak

location /path/to/script.php {
    if ($arg_id !~ ^\d+$) {
        return 403;
    }
}

S
stavinsky, 2013-07-04
@stavinsky

I dare to assume that .{7} is 7 any characters, not just numbers. may go in the direction of \d{7} or I don't really remember how it is in nginx. Plus maybe you have other options there further?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question