redirect some IP addresses

Jiff nginx-forum at nginx.us
Wed Jun 29 09:11:38 MSD 2011


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: http://forum.nginx.org/read.php?2,210944,210944#msg-210944




More information about the nginx mailing list