T
T
TechNOIR2019-08-29 17:26:57
Nginx
TechNOIR, 2019-08-29 17:26:57

nginx. How to correctly specify the location in the config for this case? Regexp?

Good afternoon. There are links like this
https://site.com/mddd/service/test/exec-post?f=mod... etc.
I want to deny access to them via location in the Nginx config for certain subnets via allow deny
I try
location /mddd/service/test/exec-post?f=modules.testmodules(.*)$ {
blah blah blah
}
But it doesn't work( Please tell me. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-08-29
@TechNOIR

For example, restrict access to subnets 192.168.1.0/24, 10.1.0.0/16

geo $a {
    default        0;
    192.168.1.0/24 1;
    10.1.0.0/16    1;
}

map $a$request_uri $b {
    default        0;
    ~^1/mddd/service/test/exec-post\?f=modules\.testmodules  1;
}

server {
    if ($b) {
        return 403;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question