N
N
NO_GLITCH2018-09-06 18:49:43
Nginx
NO_GLITCH, 2018-09-06 18:49:43

How to generate a regular expression for nginx?

It is necessary to return 403 if the length value of key !=6 and contains something other than numbers / letters
The last attempt was like this:

map $request_uri $blocker {
 "~ !^/status/?key=([0-9a-zA-Z]{6})$" "1";
}

if ($blocker) { return 403;}

Tell me how to implement

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
O. J, 2018-09-06
@NO_GLITCH

##/status?key=123222
 if ($request_uri !~ "\/status\?key=([0-9a-zA-Z]{6})$") {
       return 403;
 }
##/status/?key=123222
 if ($request_uri !~ "\/status\/\?key=([0-9a-zA-Z]{6})$") {
       return 403;
 }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question