C
C
cougar7192016-11-09 12:03:48
Nginx
cougar719, 2016-11-09 12:03:48

How to prevent nginx from accessing a specific url?

Such a situation, you need to prohibit access from all ip addresses, except for certain ones, to www.example.ru/en/safe/. At what such way really does not exist. rewrite enabled.
such rewrite
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?url=$1 last;
}
}
With such an entry, it gives 404
location /en/safe {
allow (my ip);
deny all;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Godless, 2016-11-09
@cougar719

there is no nginx at hand, you need to check:
rewrite.inc:

try_files $uri $uri/ /index.php?$args;
      if (!-e $request_filename){
            rewrite ^/(.*)$ /index.php?url=$1 last;
      }

Somewhere in the main:
index index.php index.html;

location /en/safe {
      allow (мой айпи);
      deny all;

      include rewrite.inc;
} 

location / {
       include rewrite.inc;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question