Hi forumers,
As I can’t test it, I’d like to know if my redirect code is correct or
not:
location / {
if ($remote_addr ~ “^(62.160.71.0/24)”){
rewrite ^/(.)$ /operation_deny3m.html
permanent;
}
if ($remote_addr ~ “^(84.233.174.48/28)”){
rewrite ^/(.)$ /operation_deny3m.html
permanent;
}
if ($remote_addr ~ “^(80.118.39.160/27)”){
rewrite ^/(.*)$ /operation_deny3m.html
permanent;
}
try_files $uri $uri/ @dokuwiki;
}
location @dokuwiki {
# Rewriting clean URLs
rewrite ^/_media/(.*)
/lib/exe/fetch.php?media=$1 last;
…
Thanks,
Jiff
Posted at Nginx Forum:
Jiff
2
Hello!
On Wed, Jun 29, 2011 at 01:11:38AM -0400, Jiff wrote:
Hi forumers,
As I can’t test it, I’d like to know if my redirect code is correct or
not:
location / {
if ($remote_addr ~ “^(62.160.71.0/24)”){
No, this is clearly incorrect and won’t work. Use
deny 62.160.71.0/24;
instead, see http://wiki.nginx.org/HttpAccessModule for details.
Normally this will return 403 error, though this may be easily
redefined with error_page directive (see
http://wiki.nginx.org/HttpCoreModule#error_page).
If you do really need “if” testing instead of client addresses,
use geo module (http://wiki.nginx.org/HttpGeoModule) for CIDR
testing.
Maxim D.
Jiff
3
Thanks, deny + redirecting toward my own 403 page will do 
Posted at Nginx Forum: