how to forbid using ip to visite my website

Igor Sysoev is at rambler-co.ru
Sat Nov 22 21:44:54 MSK 2008


On Sat, Nov 22, 2008 at 01:29:09PM -0500, Calomel wrote:

> One way is with an "if" statement.
> 
> ## Only requests to our Host are allowed
>       if ($host !~ ^(mydomain\.com|www\.mydomain\.com)$) {
>          return 444;
>       }

No, this is the worst way.
The right one is:

     server {
         server_name  _;  #default
         return 444;
     }

     server {
         server_name  mydomain.com
                      www.mydomain.com

                      # you may also
                      1.1.1.1 # allow IP-address
                      ""      # allow access without "Host" header, 0.7.11+

                      ;
         ...
     }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list